Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wordpress MD5 Password

I need to insert users into a Wordpress blog via a PHP script or MySQL, and I have a plain 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 the passwords all look different from what the Wordpress passwords look like now. All the passwords all start with $P$B

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

like image 663
Matt Elhotiby Avatar asked Jan 20 '11 17:01

Matt Elhotiby


1 Answers

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

However, if this isn't an option, you could simply extract the wp_generate_password function (it's in /wp-includes/pluggable.php) and relevant support functions.

like image 176
John Parker Avatar answered Sep 24 '22 23:09

John Parker