Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
general-topic
User DB issue
Avatar
tobbe
Member
Free Members
sp_UserOfflineSmall Offline
Mar 23, 2012 - 9:04 am

So I recently removed unactive users of my site but want to keep their posts.

The issues I have is:

1. The user is removed through WP-Admin interface, all that users points get attributed
to the user "NULL" which makes a graphical avatar/info that appears to be a "guest posts".

I would like to be able to attribute all those posts to a user I have created called "removed account"
to still keep the posts but make the distinction that it's no longer a valid user. How do I do this?

 

2. I accidently deleted a user, I created a new account for him and would like his old posts to be
attributed to him. due to the issue above I can't simply go into phpmyadmin and change all the
"Null values" to his user id as he would get a bunch of posts including replies to his posts
so it wouldn't make much sense.

I wonder how I can effectivly fix this. There is a solution where I manually have to use the admin
function of attributing post to new user but with near 300 posts I'd rather not go that route.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Mar 23, 2012 - 10:44 am

#1 currently we do not have a way to reassign posts to another user when you delete that user...  we do have a ticket open to add this capability, but its not there now...  currently, the posts will get changed to guest post when your remove the user... the posts are not deleted... 

so you would want to do the reassigning before you delete the user...  and as you mention, this can be tedious with the forum tools...  if large number of users, probably easier to do via phpmyadmin or other db tool...

#2 once the user has been deleted, this becomes more problematic as you note...  the posts have already been attributed to a guest poster... so of course there is no built in UI to allow you to change them back... we would run into the same problem that you mention with phpmyadmin... it really needs to be handled before the user is removed...

you might be able to do a phpmyadmin reassignment based on the guest email address... when the user is deleted and the post is converted to a guest post, his email from the account is listed as the guest email... so you only would reassign via query the guest posts with that email address instead of all null user ids...

Avatar
tobbe
Member
Free Members
sp_UserOfflineSmall Offline
Mar 23, 2012 - 12:00 pm

So the way to go (for now) would be to use phpmyadmin BEFORE a user is removed
and do a replace "old user id" with the user id of the "removed user account". I'm no
expert in phpmyadmin but I remember having followed some tutorial ages ago to do a
search and replace for a specific value.

I will see if I can dig up the command line on how to do this if you think this is a valid
approach?

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Mar 23, 2012 - 12:59 pm

yes. you will need to do this for the sftopics and sfposts table...  the former in case the user started the topic..

update wp_sftopics set user_id = xxxx where user_id = yyyy

update wp_sfposts set user_id = xxxx where user_id = yyyy

you db prefix might be other than wp_...  replace xxxx with the new user id and yyyy with the old user_id...  note, this will leave the poster ip wrong, but you could change that if you really cared too...

also, this will leave the post counts incorrect for the users...  you will need to update the posts column in the sfmembers table if you need that to be accurate...

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17361
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625