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.

In my multisite i'm using a custom blog registration using : wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta); and the site creation is successfull.

and i want users automatically sign into their site admin panel on signup,for that i use :

$creds = array();
$creds['user_login'] = $_POST['username'];
$creds['user_password'] = $_POST['password'];
$creds['remember'] = true;

$user = wp_signon( $creds, false );

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

But this will return an error :

ERROR: The password you entered for the username mysite is incorrect. Lost your password?

i need auto signin without using a plugin!!!

Please help...

share|improve this question
    
I am seeing the exact same issue. wp_signon does not seem to work for multisite setup. Did you found a solution? –  ltfishie Mar 2 '12 at 21:15
add comment

2 Answers 2

Hope this helps someone else. After hours of debugging, I found out that under multisite setup, wp_signon ($creds, false) will not log you in. So you should either do:

$user = wp_signon ($creds, false);
wp_set_auth_cookie($user->ID);

or

$user = wp_signon ($creds, true);
share|improve this answer
add comment

Since you are making them signed in after a successful blog creation, $_POST variable won't have the values you are expecting it to.

Use wp_set_auth_cookie( $user_id ); and it will make your user logged in, you don't need to check for login credentials in your use case.

share|improve this answer
    
Thanks for your response!!! But when i echo the $_POST['username']; and $_POST['password']; it gives exact values,,then what is the problem with the code? –  Sebin Aug 12 '11 at 7:00
    
@Sebin Please post your full code. I thought you are doing it when the blog's activation like is clicked, which is how it should be. Are you doing it even before that activation process, the point where the user just fills in the new blog info? –  Ashfame Aug 12 '11 at 9:19
add comment

Your Answer

 
discard

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.