I want to make a user-create snippet, but it must not includes plain password.
$ wp user create username [email protected] --role=administrator --user_pass=password
So can I create (or update) user password by hashed value?
I want to make a user-create snippet, but it must not includes plain password.
$ wp user create username [email protected] --role=administrator --user_pass=password
So can I create (or update) user password by hashed value?
There is not "one command" in Wordpress CLI that does the job: https://github.com/wp-cli/wp-cli/issues/2270
However using other commands, you can overide the user password directly in the database using the following:
USER_ID=$(wp user list --login="$USR_LOGIN" --format=ids)
wp db query "UPDATE wp_users SET user_pass='$HASHED_PASS' WHERE ID = $USER_ID;"
First line is optional if you already know the user ID.
To hash a password, use the following:
wp eval "echo wp_hash_password('$CLEAR_PASSWORD');"
I know this is an old question, but I found this while looking for a similar solution. Best solution (unless you alter the DB directly) seems to be the --prompt argument. You can pass the new password over stdin with
wp user update <USER> --prompt=user_pass
This avoids having the PW show up in your history/process list.