WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
up vote 3 down vote accepted

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().

share|improve this answer
tnx for response – user1147 Nov 2 '10 at 6:48
You are welcome – sorich87 Nov 2 '10 at 7:19

I use this wp_signon, but if on next line of code I do is_user_logged_in() and get false in return. Have I misunderstood wp_signon?

share|improve this answer
try to redirect on some other page,to refresh page,and than check is_user_logged_in(); – user1147 Nov 4 '10 at 12:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.