I want to make a user-create snippet, but it must not includes plain password.

   $ wp user create username username@example.com --role=administrator --user_pass=password

So can I create (or update) user password by hashed value?

3 Answers 3


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');"

This should work:

wp user update USERNAME --user_pass=PASSWORD

Found it here

  • While this link may answer the question, it is better to include the essential parts of the answer here and provide the link for reference. Link-only answers can become invalid if the linked page changes. - From Review
    – cjbj
    Dec 5, 2016 at 12:32
  • 1
    @cjbj The link was simply stating where I got the answer from... It has nothing to do with the actual answer
    – thebigtine
    Dec 5, 2016 at 12:37
  • Is it plain text password, isn't it? Dec 6, 2016 at 2:02

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.