有时候我们自己被锁定在WordPress后端,主要是因为忘记了密码。大多数情况下,您可以通过电子邮件重置密码 但是你有时也会忘记你的电子邮件密码。不好了!这太可怕了。
在这里我介绍一种通过FTP /文件管理器创建一个新的PHP脚本临时WordPress管理帐户的方法,这样您就可以进入,更改旧帐户的密码,然后使用旧帐户登录,然后删除临时帐户。
// ADD NEW ADMIN USER TO WORDPRESS
// ----------------------------------
// Put this file in your WordPress root directory and run it from your browser.
// Delete it when you're done. zuimoban.com
require_once('wp-blog-header.php');
require_once('wp-includes/registration.php');
// CONFIG
$newusername = 'zuimoban';
$newpassword = 'zuimoban';
$newemail = 'admin@zuimoban.com';
// Make sure you set CONFIG variables
if ( $newpassword != 'YOURPASSWORD' && $newemail != 'YOUREMAIL@TEST.com' && $newusername !='YOURUSERNAME' )
{
// Check that user doesn't already exist
if ( !username_exists($newusername) && !email_exists($newemail) )
{
// Create user and set role to administrator
$user_id = wp_create_user( $newusername, $newpassword, $newemail);
if ( is_int($user_id) )
{
$wp_user_object = new WP_User($user_id);
$wp_user_object->set_role('administrator');
echo 'Successfully created new admin user. Now delete this file!';
}
else {
echo 'Error with wp_insert_user. No users were created.';
}
}
else {
echo 'This user or email already exists. Nothing was done.';
}
}
else {
echo "Whoops, looks like you didn't set a password, username, or email before running the script. Set these variables and try again.";
}
创建一个新的PHP文件并放入代码中。根据需要更改粗体字。这将是您的临时帐户的凭据。
$newusername = 'zuimoban';
$newpassword = 'zuimoban';
$newemail = 'admin@zuimoban.com';
将php文件上传到WordPress的根目录。并在浏览器中访问该文件。例如:
http://域名/create_new_account.php
一旦访问过,将创建具有您刚设置的凭据的新帐户。就找回wordpress后台管理密码了.