Several ways to change wordpress password management

Source: Internet
Author: User
Tags php file administrator password change wordpress password wordpress login


1. wordpress provides the mailbox password retrieval function. This function is very useful. First, you need to click "forgot password" in the background and then output your senior administrator's mailbox. wordpress will automatically send you an email, just click the link in the email to reset it. This method is the simplest and most practical, but the only bad thing is that your space must support the mail function, otherwise, wordpress cannot send you an email.

2. Execute SQL in phpmyadmin to update the administrator password. This method requires the permission of the mysql database, so you don't need to talk about the principle. The password will be saved in the database, we only used SQL update to update the password. Execute the following SQL statement:


Update user set password = password ("new password") where user = 'Administrator username ';

3. If neither of the first two methods works, you can only use the following method. This method is updated through the php file. This code implements wordpress login without a senior administrator, when running this file, it will directly go to the background, and then update the password, but remember to delete the file after the password is changed. The code is as follows:


<? Php
Require ('WP-blog-header.php ');
$ Query_str = "select id from $ wpdb-> users ";
$ User_ids = $ wpdb-> get_results ($ query_str );
Foreach ($ user_ids as $ uid ){
$ User_id = $ uid-> ID;
If (user_can ($ user_id, 'admin ')){
$ User_info = get_userdata ($ user_id );
$ User_login = $ user_info-> user_login;
Wp_set_current_user ($ user_id, $ user_login );
Wp_set_auth_cookie ($ user_id );
Do_action ('WP _ login', $ user_login );
Echo "You are logged in as $ user_login ";
If (function_exists ('Get _ admin_url ')){
Wp_redirect (get_admin_url ());
} Else {
Wp_redirect (get_bloginfo ('wpurl'). '/wp-admin ');
        }
Exit;
    }
}
?>

Save this code to a file, such as the xiariboke. php file, and then run it in the browser to enter the background. Update your password.


Method 3: copy and save the following code as a password-resetter.php file, upload it to the website root directory, run the file, enter the password to reset.
<? Php
// Password resetter
Include ("wp-config.php ");
Include ("wp-blog-header.php ");
If (empty ($ _ POST ['emergency _ pass']) {
?>
<Form method = "post">
Set admin password: <input name = "emergency_pass" type = "password"/>
<Input type = "submit"/>
</Form>
<? Php
} Else {
$ SQL = "UPDATE ". $ wpdb-> users. "SET user_pass = '". md5 ($ _ POST ['ergency _ pass']). "'Where User_login = 'admin '";
$ Link = $ wpdb-> query ($ SQL );
Wp_redirect ('WP-login. Php ');
Exit ();
}
?>

Method 2 and method 3 are very similar, but I think Method 3 is better, because we can directly modify it on the WEB interface.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.