Esempio n. 1
0
 public static function bigapp_auth_login($redirect_to, $requested_redirect_to, $user)
 {
     if (!isset($_GET[BigAppConf::$app_prefix])) {
         return $redirect_to;
     }
     $route_prefix = BigAppConf::$route_prefix;
     if (isset($_GET[$route_prefix]) && $_GET[$route_prefix] == 'logout') {
         bigapp_core::yz_auth_logout();
     }
     if (isset($_GET[$route_prefix]) && $_GET[$route_prefix] == 'register') {
         bigapp_core::yz_auth_register();
     }
     if (isset($_GET[$route_prefix]) && $_GET[$route_prefix] == 'getcaptcha') {
         bigapp_core::yz_auth_getcaptcha();
     }
     $result = array("error_code" => 0, "error_msg" => "success", "data" => array());
     if (!is_wp_error($user)) {
         $result['data'] = array('name' => $user->ID, 'id' => $user->ID, 'nice_name' => $user->user_nicename, 'email' => $user->user_email, 'reg_time' => strtotime($user->user_registered), 'status' => $user->user_status, 'display_name' => $user->display_name, 'roles' => $user->roles, 'logout_url' => wp_create_nonce('logout'));
     } else {
         $error = $user->get_error_code();
         $result['error_code'] = $error;
         $result['error_msg'] = str_replace('<strong>', '', $user->get_error_messages());
         $result['error_msg'] = str_replace('</strong>', '', $result['error_msg']);
         $result['error_msg'] = preg_replace('/<a href="(.*?)">/', '', $result['error_msg']);
         $result['error_msg'] = str_replace('</a>', '', $result['error_msg']);
     }
     bigapp_core::set_response($result);
 }