I just simple edit below function with few lines of code and it works like charm.
public function validate_auth_cookie() {
global $json_api;
if (!$json_api->query->cookie) {
$json_api->error(“You must include a ‘cookie’ authentication cookie. Use the create_auth_cookie
method.”);
}
$valid = wp_validate_auth_cookie($json_api->query->cookie, ‘logged_in’) ? true : false;
$userid = wp_validate_auth_cookie($json_api->query->cookie, ‘logged_in’);
// print_r($userid);
// print_r(get_userdata( $userid ));
$data = get_userdata( $userid );
$username = $data->user_login;
// print_r($username );
// require(‘../wp-blog-header.php’);
$user_login = $username;
$user = get_userdatabylogin($user_login);
// print_r($user);
$user_id = $user->ID;
$dsf=wp_set_current_user($user_id, $user_login);
// print_r($dsf);
$sdf=wp_set_auth_cookie($user_id);
// print_r($sdf);
$datas=do_action(‘wp_login’, $user_login);
// print_r($datas);
// exit;
wp_redirect( get_site_url(), 301 ); //exit;
// exit;
if($userid) {
$creds = array();
// $creds[‘user_login’] = ‘add’;// $json_api->query->username;
// $creds[‘user_password’] = ‘add’; // $json_api->query->password;
$creds[‘remember’] = true;
$user = wp_signon( $creds, false );
if ( is_wp_error($user) )
echo $user->get_error_message();
wp_redirect( get_site_url(), 301 ); exit;
}
else
{
return array(“valid” => $valid);
}
}
Thanks Ali Qureshi your plugin works great…