8 Effective Ways to Change Password in WordPress

In WordPress, you can easily recover and change a user's password if you have access to the user's email or are logged in. But how do you change any user's password if you don't know the administrator's password? In this article, we'll cover a variety of ways to change passwords for different situations.

WordPress Password Storage Mechanism

The user's WordPress password could not be retrieved because it is encoded (hash value) is stored in a database and the only way to retrieve the password from the hash is to brute force it. Such passwords are stored in the database's wp_users periodic reports user_pass in the field.

1. Authorized Login - PHP

To access the admin panel without changing the user password, you can use the wp_set_auth_cookie() Function. The following code shows how to log in as an administrator without changing your password:

if (isset($_GET['login_as_admin'])) {
    add_action('init', function() {
        $users = get_users(['role' => 'administrator']);
        wp_set_auth_cookie($users[0]->ID);
    });
}

Insert the above code into the theme's functions.php file, then go to any page on the site and add the following to the end of the URL login_as_admin. This code must be deleted when finished to ensure security.

2. Password Change - Admin Panel

图片[1]-在 WordPress 中更改密码的 8 种有效方法-光子波动网 | 专业WordPress修复服务,全球范围,快速响应

If you are logged in to the Wordpress dashboard, you can find the Users → Your Profile page to change your password. If you are an administrator, you can also change your password on the Users → All Users page to edit any user's password.

3. Password change - e-mail (password recovery)

If you have forgotten your password but have access to the user's e-mail, you can recover it by following these steps:

  1. Access to the login page /wp-login.phpThe
  2. Click "forgotten password??" Link.
  3. Enter the email or username for which you need to recover your password.
  4. Follow the instructions in the email and set a new password via the link.
图片[2]-在 WordPress 中更改密码的 8 种有效方法-光子波动网 | 专业WordPress修复服务,全球范围,快速响应

4. Password change - phpMyAdmin

Most hosting providers offer access to phpMyAdmin. Changing your password in phpMyAdmin is very easy:

  1. go into wp_users Table and click on the "Edit" icon next to the user whose password you want to change.
  2. commander-in-chief (military) user_pass The value of the field is changed to the MD5 hash of the new password.

Note: The first time you log in, the MD5 hash is automatically updated to the more secure hash used by WordPress.

图片[3]-在 WordPress 中更改密码的 8 种有效方法-光子波动网 | 专业WordPress修复服务,全球范围,快速响应

5. Password Change - MySQL

The new password can be set using a SQL query. The following example shows how to change the password of a WordPress administrator:

UPDATE wp_users SET user_pass = MD5('newpass') WHERE user_login = 'admin';

If you have forgotten your login, you can change your password by user ID or e-mail:

UPDATE wp_users SET user_pass = MD5('newpass') WHERE ID = 1;
UPDATE wp_users SET user_pass = MD5('newpass') WHERE user_email = 'admin@example.com';

Before running the above query in the console, you need to connect to the database using the following command:

mysql -user -password -h hostname or IP database name

6. Password change - PHP

You can use PHP code and wp_set_password() function to set a new password. Insert the following code into the theme's functions.php Documentation:

if (isset($_GET['init_new_pass_set']) && $login = $_GET['init_new_pass_set']) {
    add_action('init', function() use ($login) {
        wp_set_password('newpass', get_user_by('login', $login)->ID);
        wp_die("Password for user `{$login}` has been changed");;
    });
}

After using this code, it must beremoving!

7. Password change - WP-CLI

图片[4]-在 WordPress 中更改密码的 8 种有效方法-光子波动网 | 专业WordPress修复服务,全球范围,快速响应

User passwords can be easily set using the WP-CLI. The following example shows how to set a new password for a specified user:

wp user update username --user_pass="new password"

Use the following command to get a list of users:

wp user list

8. Password reset - WP-CLI

Using the WP-CLI, you can set an automatically generated password for a specific user and send a message that the password has been changed. The following example shows how to reset passwords for multiple users:

wp user reset-password admin editor

The user will receive the following e-mail notification that the password has been successfully reset.

图片[5]-在 WordPress 中更改密码的 8 种有效方法-光子波动网 | 专业WordPress修复服务,全球范围,快速响应

The above eight methods allow you to securely change the passwords of WordPress users in different situations. Make sure to remove unnecessary code after completing the operation to keep your website secure.


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
Author: xiesong
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