Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
add comment

2 Answers

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
add comment

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
add comment

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.