I have two portals one is jsp and another one is wordpress, I am trying to make common login for both portals(i.e when a user is logged in from jsp at the same time he need to log-in wordpress also ). So i write the bellow code
$creds['user_login'] =$userid[0];
$creds['user_password'] = $user_password;
$creds['remember'] = true;
$user = wp_signon( $creds, false );
// print_r($user);
if ( is_wp_error($user) ){
echo $user->get_error_message();
}else{
//echo $user->ID.'dd';
get_currentuserinfo($user->ID);
$user_id = $user->ID;
$user = get_user_by( 'id', $user_id );
if( $user ) {
wp_set_current_user( $user_id, $user->user_login );
wp_set_auth_cookie( $user_id );
do_action( 'wp_login', $user->user_login );
}
global $current_user;
get_currentuserinfo();
//echo 'Username: ' . $current_user->user_login . "
";
With the above code i can able to get logged in user details ...But when i try to go to admin it is asking for log-in credentials