php - Wordpress, create user programmatically -


how go creating wordpress users programmatically?

i using method below, user being created - when try login password gives me wrong password message, 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:

$user_id = username_exists( $user_name ); if ( !$user_id , email_exists($user_email) == false ) {     $random_password = wp_generate_password( $length=12, $include_standard_special_chars=false );     $user_id = wp_create_user( $user_name, $random_password, $user_email ); } else {     $random_password = __('user exists.  password inherited.'); } 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -