1

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

  • 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
3

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);
|improve this answer|||||
0

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.

|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

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.