I create user with wp_create_user,after succesfully creating a user I need to set his status to be logged in?How to set his status to be logged in ?


Use wp_signon(). Ex:

$creds = array();
$creds['user_login'] = 'example';
$creds['user_password'] = 'plaintextpw';
$creds['remember'] = true;

$user = wp_signon( $creds, false );

if ( is_wp_error($user) )
    echo $user->get_error_message();

See Codex for more details about wp_signon().

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.