How do I go about creating wordpress users programmatically?
I am using the method below, user is being created – but when I try to login with a password it gives me wrong password message, any suggestions please?
include 'wp-blog-header.php';
include 'wp-includes/registration.php';
include 'wp-includes/pluggable.php';
ini_set("memory_limit","1024M");
ini_set("max_execution_time", "240");
global $wpdb;
programmatically
$row = array(
'user_name' => "wacek123",
'password' => "wacek123",
'email_address' => "wacek123@gmail.com",
'name' => "wacek123",
'surname' => "wacek123"
);
$userdata = array(
'user_login' => $row["user_name"],
'user_pass' => wp_hash_password($row["password"]),
'user_nicename' => $row["user_name"],
'user_email' => $row["email_address"],
'first_name' => $row["name"],
'last_name' => $row["surname"],
'role' => 'subscriber'
);
wp_insert_user($userdata);
I’d recommand using
wp_create_user
instead:http://codex.wordpress.org/Function_Reference/wp_create_user
Example: