How to reset passwords for all users on a network using wp cli


I have a WP Network (sub directory), Sometime specially in case of security emergencies, it is generally preferred to change passwords for all users.

I am looking for a way to reset passwords by sending a password reset url
via email to each user on the network.

Goal here is to just reset all passwords and make users regenerate them through the reset password link on the front end.
Also I would like to kill all active sessions

The easiest way to do this is to regenerate all the SALTs (in .env for me)

How can I do this using wp-cli?

I am comparative new to wp-cli and found out
where it explains how I can do for an individual user.

# Update user
$ wp user update 123 --display_name=Mary --user_pass=marypass
Success: Updated user 123


But there are two problems here,

  1. The password has to be entered along with the username, which I think is not the ideal method.
  2. The user should have the freedom to select their password,(consider strong passwords are forced)

Any help, reference Urls?

I was able to make a small php files which resides on my root directory, and execute in via wp-cli and reset all the passwords at once using wp_generate_password().

Since I am working on local system right now, I did not check if it sends emails with the reset URL, which is kind of important. But that does not sound too difficult.

What I am concern right now is, I really don’t want it to be executed the way it is right now. I am using ” wp eval-file password-reset.php;”

I want it to have it more of like a function some what like “wp reset passwords” with parameters like USERROLE, USERNAME, USERID or just * for all users.

Does anyone have any idea how can I get that???

, , patilswapnilv 2 years 2020-01-14T08:38:55-05:00 0 Answers 87 views 0

Leave an answer