admin管理员组

文章数量:1122846

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

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 edited Aug 11, 2011 at 5:51 Wyck 18k4 gold badges46 silver badges67 bronze badges asked Aug 11, 2011 at 5:19 SebinSebin 232 silver badges4 bronze badges 1
  • I am seeing the exact same issue. wp_signon does not seem to work for multisite setup. Did you found a solution? – ltfishie Commented Mar 2, 2012 at 21:15
Add a comment  | 

2 Answers 2

Reset to default 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);

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.

本文标签: multisitewpsignon( credsfalse ) not working