Home > CMS Tutorial > WordPress > Modify WordPress user ID

Modify WordPress user ID

藏色散人
Release: 2019-11-09 11:38:38
forward
2779 people have browsed it

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");
Copy after login

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!

Related labels:
source:zmingcx.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template