Password Wordpress MD5

I need to insert users into a Wordpress blog through a PHP script or MySQL, and I have a simple text password. I thought I could do something like this:

$query = "INSERT INTO $new_db.wp_users (user_login, user_pass, user_nicename) select user_email, md5(user_password), user_name from $source_db.users"; 

But all passwords look different than Wordpress passwords now look. All passwords start with $P$B

From reading, he says that there is salt ... is there a way to take a password, for example test123, and turn it into the encrypted password that Wordpress expects?

+4
source share
4 answers

The most sensible solution would be to simply use the appropriate WordPress function ( wp_generate_password ).

However, if this is not an option, you can simply extract the wp_generate_password function (it is in / wp -includes / pluggable.php) and the corresponding helper functions.

+5
source

Wordpress uses phpass hashing, which is different from MD5.

+1
source

The easiest way to create a password is ...

  • use any garbage as an entry in the MySQL table for user_pass but the correct email address.
  • Use the "forgotten password" function in the login panel to create the correct password (or activate this link automatically to notify the user).

Remember to copy wp_capabilities and wp_user_level from another account.

+1
source

This function will do what you described to convert the password:

 <? function encrypt_for_wordpress($plain_text_password) { return md5("\$P\$B" . $plain_text_password); } 

You need to select it from source_db , convert it to PHP, and then paste it into new_db .

-1
source

Source: https://habr.com/ru/post/1336349/


All Articles