Home  >  Article  >  CMS Tutorial  >  Modify WordPress user ID

Modify WordPress user ID

藏色散人
藏色散人forward
2019-11-09 11:38:382703browse

The following column WordPress Tutorial will introduce to you how to modify the WordPress user ID. I hope it will be helpful to friends in need!

Modify WordPress user ID

Modify WordPress user ID

Sometimes the default user is deleted because the login name of the default user when installing WordPress cannot be modified. , create a new administrative user, but the newly created account ID is not 1. I feel uncomfortable. You can modify the user ID through the following method.

Add the following code to the current theme function template functions.php:

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");

This example is to change the user with ID 2 to ID 1. The corresponding user can be modified according to the implementation situation. ID number.

Refresh the page and see if the management user ID has changed to 1.

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

The above is the detailed content of Modify WordPress user ID. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:zmingcx.com. If there is any infringement, please contact admin@php.cn delete