admin管理员组

文章数量:1128538

Is this enough to change the user ID? I'm doing this for security purposes, where the administrator has user ID=1 and I want to keep all posts, pages and content.

UPDATE wp_posts SET post_author='1000' WHERE post_author='1';
UPDATE wp_users SET ID = '1000' WHERE ID = '1';
UPDATE wp_usermeta SET user_id = '1000' WHERE user_id = '1';

ALTER TABLE wp_users AUTO_INCREMENT = 1001;

Is there a WordPress function to do it globally?

Is this enough to change the user ID? I'm doing this for security purposes, where the administrator has user ID=1 and I want to keep all posts, pages and content.

UPDATE wp_posts SET post_author='1000' WHERE post_author='1';
UPDATE wp_users SET ID = '1000' WHERE ID = '1';
UPDATE wp_usermeta SET user_id = '1000' WHERE user_id = '1';

ALTER TABLE wp_users AUTO_INCREMENT = 1001;

Is there a WordPress function to do it globally?

Share Improve this question asked Mar 18, 2015 at 17:07 CiprianCiprian 8802 gold badges11 silver badges27 bronze badges 2
  • How does this makes WP more secure? – user42826 Commented Mar 18, 2015 at 19:38
  • It doesn't. Some security plugins report there's a username with ID 1, and some clients are worried about this. Changing the ID will make the plugin report the site as secure. – Ciprian Commented Mar 19, 2015 at 10:33
Add a comment  | 

3 Answers 3

Reset to default 1

Why not make a new account for this user which will generate a new database ID. Then delete the user with the ID of 1 and attribute all posts / content to the new user you created for them? Then you don't have to worry about queries or messing up your database. Also, as said before this makes absolutely no sense from a security standpoint as it's pointless. If your client doesn't trust you enough and wants to micromanage the site security they clearly know nothing about, might be time to dump that client.

If you would like to also keep comments:

UPDATE wp_comments SET user_id = 1000 WHERE user_id = 1;

It should work but it doesn't add even the tiniest security to the site (if the bad guy has enough permissions to alter the password of the admin he can probably create an admin user for himself). Don't forget to backup before running the queries.

本文标签: securityHow to change WordPress user ID