How to Change WordPress User IDs

在WordPress使用过程中,有些用户被删除了,ID就被空出来了,那么想后面注册的用户,使用这些未占用的ID,我们要怎么去修改呢?那么本文,将介绍以下如果修改WordPress用户的ID。

只需要在funtions文件里添加代码就可以搞定了。

将下面的代码添加到当前主题 functions.php file中(路径 /wp-content/themes/你的主题名/funtions.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");
图片[1]-如何修改WordPress的用户ID-光子波动网 | 专业WordPress修复服务,全球范围,快速响应

本代码是将用户ID为 2 的用户改为ID 1,可以根据实现情况,修改对应的ID数字。

刷新一下页面,看看是不是管理用户ID变成1了。

修改后,将代码删除,没有必要留在主题中。

draw attention to sth.:修改前请做好数据库备份,以防万一!

图片[2]-如何修改WordPress的用户ID-光子波动网 | 专业WordPress修复服务,全球范围,快速响应

Contact Us
Can't read the article? Contact us for free answers! Free help for personal, small business sites!
Tel: 020-2206-9892
QQ咨询:1025174874
(iii) E-mail: info@361sale.com
Working hours: Monday to Friday, 9:30-18:30, holidays off
© Reprint statement
本文作者: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