How to Change WordPress User IDs

In the process of WordPress use, some users are deleted, ID is empty, then want to register behind the user, use these unoccupied ID, how do we go to modify it? Then this article, will introduce the following if you modify the WordPress user ID.

Just add the code to the funtions file and you're all set.

Add the following code to the current theme functions.php filein (Path /wp-content/themes/your-theme-name/funtions.php) The following code is added to the bottom of the file, below:

global $wpdb;
$wpdb->query("UPDATE wp_users SET ID = 1 WHERE ID = 2");
$wpdb->query("UPDATE wp_usermeta SET user_id = 1 WHERE user_id = 2");
$wpdb->query("UPDATE wp_posts SET post_author = 1 WHERE post_author = 2");
$wpdb->query("UPDATE wp_comments SET user_id = 1 WHERE user_id = 2");
图片[1]-如何修改WordPress的用户ID-光子波动网 | WordPress教程、Elementor教程与故障修复

This code is to change the user ID of 2 to ID 1. You can change the corresponding ID number according to the realization.

Refresh the page and see if the Admin User ID changes to 1.

After modification, remove the code, there is no need to leave it in the theme.

draw attention to sth.: Please do this before modifyingDatabase BackupJust in case!

图片[2]-如何修改WordPress的用户ID-光子波动网 | WordPress教程、Elementor教程与故障修复

Contact Us
Can't read the tutorial? Contact us for a free answer! Free help for personal, small business sites!
客服微信
Customer Service
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: [email protected]
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
This article was written by Jack
THE END
If you like it, support it.
kudos0 share (joys, benefits, privileges etc) with others
commentaries sofa-buying

Please log in to post a comment

    No comments