Support Forum

Mass reasign posts

SS Shari Smith
Shari Smith
Member

Hi due to the issue with the attacks against the admin account in wordpress I’ve deleted that account. We’d like to reassign all the posts to another user so a name still shows up. It’s hundreds of post. Do you know of anyway to accomplish this?

ie: replace user id with user id 643.

Thanks!

13 Answers

New Answer

MP Mr Papa
Mr Papa
Member

this is quite involved…  the user id is widespread throughout the database…  sfmembers, sftopics, sfposts, sfmemberships, sfmessages, users, user_meta immediately come to mind… but there are several others related to plugins and ones not on the tip of my tongue…

 

SS Shari Smith
Shari Smith
Member

I’m just looking to replace it in the post like you would through the toolbox, however it would take hours to do that manually. So I was thinking I just need to replace it in the user_id of the sfposts table. But wasn’t sure if I did that, if it would work. I’ve also not found a way to do an exact match find and replace with phpmyadmin.

 

MP Mr Papa
Mr Papa
Member

that is much, much simpler than moving a user…  you would move the post to a new user, but the user new would not inherit thinks like subscriptions, permissions, memberships, capabilities, etc etc etc…

fair warning, but if all you want to do is reassign a post to another user id, all of one user to another, this should work in phpmyadmin:

UPDATE wp_sfposts SET user_id = xxx where user_id = yyy;

xxx is the new user id and yyy is the old user id…  but again, caution.. you might want to have a db backup before you proceed.. just in case… ;)

and your wp db prefix might not be wp_….

SS Shari Smith
Shari Smith
Member

I have a local environment to test this, so THANK YOU!!! :)

SS Shari Smith
Shari Smith
Member

Looks like it worked. I’m so excited.. I’ll make sure to test a few thing just to make sure but that looks to have done the trick.

Thank you Thank you Mr. Papa!!!!

MP Mr Papa
Mr Papa
Member

np. glad to help…

I should add that in the next version after 5.3 (which is just waiting on wp 3.6), we will be working on a way to delete users with more options including reassigning everything to a new user (hopefully!)…

MP Mr Papa
Mr Papa
Member

just have to see what is realistic! ;)

but we need  more options for deleting a user than just moving posts to being from a guest… but if the user is being deleted, it will probably be a mass reassign like you wanted…  or maybe allow posts to be deleted.. or assigned to guest (like today)… or other…

YS Yellow Swordfish
Yellow Swordfish
Member

It’s worth pointing out that while WordPress does not support changing a users login name through the UI – and it is the login name ‘admin’ we are talking about here in particular – then actually manually changing that login name in the database ‘users’ table will work and is effective in removing the target ‘admin’ from the database.

SS Shari Smith
Shari Smith
Member

I never thought to even try that. Is that true for any user? So if someone wanted to change their user name it is possible? Not that I would make a point of it, but I have had a case where they used their password, and we had to close and reopen a new membership account. In that case the change via the database would have been much faster.

YS Yellow Swordfish
Yellow Swordfish
Member

Yes it is the case for all users. I am talking general WordPress here. If you have any other plugins that store the login name then this would be a problem. But all good plugins should use the WP table (users) to get the login name and user id pairing.

I guess this is not something the WordPress team will tell you but I have done this many times. Try it on your test site…

SS Shari Smith
Shari Smith
Member

Great! I’ll give it a whirl.. I’m doing this for all my clients to help remove the threat, so that would be a bit quicker.

MP Mr Papa
Mr Papa
Member

let us know how you make out…  there is also some wp plugins that do this for you… though they tend to be overkill…