• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP wp_set_auth_cookie函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中wp_set_auth_cookie函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_set_auth_cookie函数的具体用法?PHP wp_set_auth_cookie怎么用?PHP wp_set_auth_cookie使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了wp_set_auth_cookie函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。

示例1: force_ssl_cookie

 function force_ssl_cookie($errors, $user_id)
 {
     if (empty($errors)) {
         wp_set_auth_cookie($user_id, true, true);
         wp_set_current_user($user_id);
     }
 }
开发者ID:vilmark,项目名称:vilmark_main,代码行数:7,代码来源:gateway.authorizenetarb.php


示例2: facebook_login

 /**
  * Maps our FB response fields to the correct user fields as found in wp_update_user. Then
  * calls setUpNewFacebookUser, and passes the correct response via JSON to JS.
  *
  * @since 2.0.0
  *
  * @return  JSON    A JSON object
  */
 public function facebook_login()
 {
     check_ajax_referer('facebook-nonce', 'security');
     $user = array('username' => $_POST['fb_response']['id'], 'user_login' => $_POST['fb_response']['id'], 'first_name' => $_POST['fb_response']['first_name'], 'last_name' => $_POST['fb_response']['last_name'], 'email' => $_POST['fb_response']['email'], 'user_url' => $_POST['fb_response']['link'], 'fb_id' => $_POST['fb_response']['id']);
     if (empty($user['username'])) {
         $status = $this->_zm_alr_helpers->status('invalid_username');
         $user_id = false;
     } else {
         $user_obj = get_user_by('login', $user['user_login']);
         if ($user_obj == false) {
             $user_obj = $this->setupNewFacebookUser($user);
         }
         // A WP user account already exists that is NOT associated with a FB account
         if ($user_obj == 'existing_user_email') {
             $status = $this->_zm_alr_helpers->status('username_exists');
         } elseif ($user_obj) {
             $user_id = $user_obj->ID;
             wp_set_auth_cookie($user_id, true);
             $status = $this->_zm_alr_helpers->status('success_login');
         } else {
             $status = $this->_zm_alr_helpers->status('invalid_username');
         }
     }
     $status = array_merge($status, $this->registerRedirect($user['user_login']));
     wp_send_json($status);
 }
开发者ID:JustManG,项目名称:Kursovaya,代码行数:34,代码来源:ALRSocialFacebook.php


示例3: login

 /**
  * custom log in functionality, from custom log in page
  */
 static function login()
 {
     if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], 'login')) {
         return;
     }
     if (is_email($_POST['email'])) {
         $user = get_user_by('email', $_POST['email']);
         if (empty($user)) {
             Kanban_Flash::flash(__('Whoops! We can\'t find an account for that email address.', 'kanban'), 'danger');
             wp_redirect($_POST['_wp_http_referer']);
             exit;
         }
     } else {
         $user = get_user_by('login', $_POST['email']);
         if (empty($user)) {
             Kanban_Flash::flash(__('Whoops! We can\'t find an account for that username.', 'kanban'), 'danger');
             wp_redirect($_POST['_wp_http_referer']);
             exit;
         }
     }
     $creds = array();
     $creds['user_login'] = $user->user_login;
     $creds['user_password'] = $_POST['password'];
     $creds['remember'] = true;
     $user = wp_signon($creds, false);
     if (is_wp_error($user)) {
         Kanban_Flash::flash(__('Whoops! That password is incorrect for this email address.', 'kanban'), 'danger');
         wp_redirect($_POST['_wp_http_referer']);
         exit;
     }
     wp_set_current_user($user->ID);
     wp_set_auth_cookie($user->ID);
     wp_redirect(sprintf('%s/%s/board', site_url(), Kanban::$slug));
     exit;
 }
开发者ID:gigabyte1977,项目名称:kanban,代码行数:38,代码来源:class-user.php


示例4: ajax_return_to_admin_panel

 function ajax_return_to_admin_panel()
 {
     global $wpdb;
     if (!empty($_POST['secure_key'])) {
         $verify = $_POST['secure_key'];
     } else {
         exit(json_encode(array('status' => false, 'message' => __("Wrong data", WPC_CLIENT_TEXT_DOMAIN))));
     }
     if (!empty($_COOKIE['wpc_key']) && is_user_logged_in()) {
         $key = $_COOKIE['wpc_key'];
         $user_data = $wpdb->get_row($wpdb->prepare("SELECT umeta_id, user_id, meta_value FROM {$wpdb->usermeta} WHERE meta_key = 'wpc_client_admin_secure_data' AND meta_value LIKE '%s'", '%"' . md5($key) . '"%'), ARRAY_A);
         if (isset($user_data['user_id']) && user_can($user_data['user_id'], 'wpc_admin_user_login') && wp_verify_nonce($verify, get_current_user_id() . $user_data['user_id'])) {
             if (!empty($user_data['meta_value'])) {
                 $secure_array = unserialize($user_data['meta_value']);
                 if (isset($secure_array['end_date']) && $secure_array['end_date'] > time()) {
                     wp_set_auth_cookie($user_data['user_id'], true);
                     $wpdb->delete($wpdb->usermeta, array('umeta_id' => $user_data['umeta_id']));
                     $secure_logged_in_cookie = 'https' === parse_url(get_option('home'), PHP_URL_SCHEME);
                     setcookie("wpc_key", '', time() - 1, SITECOOKIEPATH, COOKIE_DOMAIN, $secure_logged_in_cookie, true);
                     exit(json_encode(array('status' => true, 'message' => admin_url('admin.php?page=wpclient_clients'))));
                 }
             }
         }
     }
     exit(json_encode(array('status' => false, 'message' => __("Wrong data", WPC_CLIENT_TEXT_DOMAIN))));
 }
开发者ID:EfncoPlugins,项目名称:web-portal-lite-client-portal-secure-file-sharing-private-messaging,代码行数:26,代码来源:class.ajax.php


示例5: mm_facebook_connection_process_facebook_actions

function mm_facebook_connection_process_facebook_actions()
{
    global $user_ID;
    $current_url = mm_facebook_connection_get_current_url();
    if (mm_facebook_connection_is_conifgured()) {
        if (isset($_GET['mm_unlink_facebook']) && $_GET['mm_unlink_facebook'] == 'true') {
            update_user_meta($user_ID, 'mm_facebook_connection_facebook_id', '');
            return wp_redirect($current_url);
        }
        if (isset($_GET['code']) && $_GET['code'] && isset($_GET['mm_facebook_connection']) && $_GET['mm_facebook_connection'] == 'true') {
            $data_array = mm_facebook_connection_get_data($_GET['code'], $current_url . '?mm_facebook_connection=true');
            if (is_array($data_array) && count($data_array) > 0) {
                update_user_meta($user_ID, 'mm_facebook_connection_facebook_id', $data_array['facebook_internal_id']);
                return wp_redirect($current_url);
            }
        }
        if (isset($_GET['code']) && $_GET['code'] && isset($_GET['mm_facebook_login']) && $_GET['mm_facebook_login'] == 'true') {
            $data_array = mm_facebook_connection_get_data($_GET['code'], $current_url . '?facebook_login=true');
            $users_array = get_users(array('meta_key' => 'mm_facebook_connection_facebook_id', 'meta_value' => $data_array['facebook_internal_id']));
            if (is_array($users_array) && count($users_array) > 0) {
                $user_to_auth_obj = $users_array[0];
                if ($user_to_auth_obj) {
                    wp_set_current_user($user_to_auth_obj->ID, $user_to_auth_obj->user_login);
                    wp_set_auth_cookie($user_to_auth_obj->ID);
                    do_action('wp_login', $user_to_auth_obj->user_login);
                    return wp_redirect(home_url('/'));
                }
            }
        }
    }
}
开发者ID:rodrigo-techera,项目名称:MM-Facebook-Connect,代码行数:31,代码来源:mm-facebook-connection.php


示例6: auto_login_new_user

function auto_login_new_user($user_id)
{
    wp_set_current_user($user_id);
    wp_set_auth_cookie($user_id);
    echo 'current user: ' . wp_get_current_user()->user_login;
    wp_redirect(home_url() . '/logup?newlog=true');
}
开发者ID:tristanhamel,项目名称:cehavre,代码行数:7,代码来源:functions.php


示例7: ucenter_oauth

function ucenter_oauth()
{
    //根据授权码获取access_token
    $url = UCENTER_API . '/oauth/accessToken';
    $data = array('client_id' => CLIENT_ID, 'client_secret' => CLIENT_SECRET, 'grant_type' => 'authorization_code', 'redirect_uri' => REDIRECT_URI, 'code' => $_GET['code']);
    $response = wp_remote_post($url, array('method' => 'POST', 'body' => $data));
    $data = json_decode($response['body'], true);
    if (1 !== $data['code']) {
        wp_die('授权失败');
    }
    $access_token = $data['data']['access_token'];
    //根据access_token获取用户信息
    $url = UCENTER_API . '/user/?access_token=' . $access_token;
    $data = wp_remote_get($url);
    $data = json_decode($data['body'], true);
    if (1 !== $data['code']) {
        wp_die('获取用户信息失败');
    }
    $username = $data['data']['username'];
    $user_id = $data['data']['user_id'];
    //根据返回的用户信息登录,用户还未存在时则插入
    $current_user = get_user_by('login', $username);
    if (is_wp_error($current_user) || !$current_user) {
        $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
        $user_id = wp_insert_user(array('user_login' => $username, 'display_name' => $username, 'nick_name' => $username, 'user_pass' => $random_password));
        wp_set_auth_cookie($user_id);
    } else {
        wp_set_auth_cookie($current_user->ID);
    }
    header('Location: ' . home_url() . '/wp-admin');
    exit;
}
开发者ID:yaoshanliang,项目名称:WordPress,代码行数:32,代码来源:wp-ucenter-login.php


示例8: authenticateAction

 /**
  * Handle login submissions. Authenticate using AuthService.
  * @return 
  */
 public function authenticateAction()
 {
     $form = $this->getForm();
     $urlRedirect = false;
     $redirect = 'home';
     $params = array();
     $request = $this->getRequest();
     if ($request->isPost()) {
         $form->setData($request->getPost());
         if ($form->isValid()) {
             /* Handle Authentication */
             $username = $request->getPost('Username');
             $password = $request->getPost('Password');
             $WP_User = wp_authenticate($username, $password);
             if (is_wp_error($WP_User)) {
                 $redirect = 'login';
                 $this->flashmessenger()->addErrorMessage("Invalid User Credentials");
             } else {
                 wp_set_auth_cookie($WP_User->ID);
                 $this->flashmessenger()->addSuccessMessage("Login Successful");
             }
         } else {
             /* Form error messages */
             foreach ($form->getMessages() as $message) {
                 $this->flashmessenger()->addErrorMessage(implode(",", $message));
             }
         }
     }
     return $this->redirect()->toRoute($redirect);
 }
开发者ID:Ellipizle,项目名称:zf2-wordpress,代码行数:34,代码来源:AuthController.php


示例9: myfunction

function myfunction()
{
    //should do some database query here
    // .... ..... ..... .....
    //just some dummy result
    //$email = $wpdb->get_var("SELECT user_email FROM wp_users WHERE user_login = 'ezyva.jason' ");
    //global $wpdb;
    //$email = $wpdb->get_var("SELECT user_email FROM wp_users WHERE user_login = 'ezyva.jason' ");
    $url = "https://app.thesmsfacademy.com.au/api/auth/validate_auth_cookie/?cookie=ezyva.jason|1398140082|954a2415c23fac56ca7cf23050566c08";
    $content = file_get_contents($url);
    $json = json_decode($content, true);
    if ($json['valid']) {
        $url = "https://app.thesmsfacademy.com.au/api/auth/get_currentuserinfo/?cookie=ezyva.jason|1398140082|954a2415c23fac56ca7cf23050566c08";
        $content = file_get_contents($url);
        $json2 = json_decode($content, true);
        $user_login = $json2[user][username];
        $user = get_user_by('login', $user_login);
        $user_id = $user->ID;
        wp_set_current_user($user_id, $user_login);
        wp_set_auth_cookie($user_id);
        do_action('wp_login', $user_login);
        return 'valid';
    } else {
        return 'Invalid';
    }
}
开发者ID:Ezyva2015,项目名称:SMSF-Academy-Wordpress,代码行数:26,代码来源:wpws-index.php


示例10: json_basic_auth_handler

/**
 * Plugin Name: JSON Basic Authentication
 * Description: Basic Authentication handler for the JSON API, used for development and debugging purposes
 * Author: WordPress API Team
 * Author URI: https://github.com/WP-API
 * Version: 0.1
 * Plugin URI: https://github.com/WP-API/Basic-Auth
 */
function json_basic_auth_handler($request)
{
    global $wp_json_basic_auth_error;
    $wp_json_basic_auth_error = null;
    // Check that we're trying to authenticate
    if (!isset($_SERVER['PHP_AUTH_USER'])) {
        return $request;
    }
    $username = $_SERVER['PHP_AUTH_USER'];
    $is_email = strpos($username, '@');
    if ($is_email) {
        $ud = get_user_by_email($username);
        $username = $ud->user_login;
    }
    $password = $_SERVER['PHP_AUTH_PW'];
    $user = wp_authenticate($username, $password);
    if ($user) {
        wp_set_current_user($user->ID, $user->user_login);
        wp_set_auth_cookie($user->ID);
        do_action('wp_login', $user->user_login);
    }
    /**
     * In multi-site, wp_authenticate_spam_check filter is run on authentication. This filter calls
     * get_currentuserinfo which in turn calls the determine_current_user filter. This leads to infinite
     * recursion and a stack overflow unless the current function is removed from the determine_current_user
     * filter during authentication.
     */
    if (is_wp_error($user)) {
        $wp_json_basic_auth_error = $user;
        return null;
    }
    $wp_json_basic_auth_error = true;
    return null;
}
开发者ID:gopaulo,项目名称:Basic-Auth,代码行数:42,代码来源:basic-auth.php


示例11: bdn_is_user_auth2

function bdn_is_user_auth2()
{
    global $driveService;
    $current_user_id = get_current_user_id();
    $client = new Google_Client();
    $client->setRedirectUri(home_url('/'));
    $driveService = new Google_DriveService($client);
    $oauth2 = new Google_Oauth2Service($client);
    if (!isset($_GET['code']) && (!is_user_logged_in() || ($access_token = get_user_meta($current_user_id, '_google_access_token', true)) && $client->setAccessToken($access_token) && !$client->getAccessToken())) {
        header('Location: ' . $client->createAuthUrl());
        exit;
    }
    if (isset($_GET['code'])) {
        $client->authenticate($_GET['code']);
        $user = $oauth2->userinfo->get();
        $new_user = get_user_by('email', $user['email']);
        if (!$current_user_id) {
            wp_set_current_user($new_user->ID, $new_user->user_login);
            wp_set_auth_cookie($new_user->ID);
            do_action('wp_login', $new_user->user_login);
        } elseif ($new_user->ID == $current_user_id) {
            update_user_meta($new_user->ID, '_google_access_token', $client->getAccessToken());
        } else {
            die('Sorry, please use your BDN account');
        }
        header('Location: http://' . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF']);
    }
    return $driveService;
}
开发者ID:bangordailynews,项目名称:Newsroom-Tools,代码行数:29,代码来源:gapi.php


示例12: ins_oauth

function ins_oauth()
{
    $code = $_GET['code'];
    $url = "https://api.instagram.com/oauth/access_token";
    $data = array('client_id' => INS_APPID, 'client_secret' => INS_APPSECRET, 'grant_type' => 'authorization_code', 'redirect_uri' => home_url('/?type=instagram'), 'code' => $code);
    $response = wp_remote_post($url, array('method' => 'POST', 'body' => $data));
    $output = json_decode($response['body'], true);
    $token = $output['access_token'];
    $user = $output['user'];
    $ins_id = $user['id'];
    $name = $user['username'];
    if (!$ins_id) {
        wp_redirect(home_url('/?3' . $douban_id));
        exit;
    }
    if (is_user_logged_in()) {
        $this_user = wp_get_current_user();
        update_user_meta($this_user->ID, "instagram_id", $ins_id);
        ins_ouath_redirect();
    } else {
        $user_ins = get_users(array("meta_key " => "instagram_id", "meta_value" => $ins_id));
        if (is_wp_error($user_ins) || !count($user_ins)) {
            $login_name = wp_create_nonce($ins_id);
            $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
            $userdata = array('user_login' => $login_name, 'display_name' => $name, 'user_email' => '', 'user_pass' => $random_password, 'nick_name' => $name);
            $user_id = wp_insert_user($userdata);
            wp_signon(array("user_login" => $login_name, "user_password" => $random_password), false);
            update_user_meta($user_id, "instagram_id", $ins_id);
            ins_ouath_redirect();
        } else {
            wp_set_auth_cookie($user_ins[0]->ID);
            ins_ouath_redirect();
        }
    }
}
开发者ID:AlwaysOnline,项目名称:wp-oauth,代码行数:35,代码来源:instagram.php


示例13: sso_check

/**
Plugin Name: SSO
Author: Garth Mortensen, Mike Hansen
Version: 0.1
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
function sso_check()
{
    if (!isset($_GET['salt']) || !isset($_GET['nonce']) || !isset($_GET['user'])) {
        sso_req_login();
    }
    if (sso_check_blocked()) {
        sso_req_login();
    }
    $nonce = esc_attr($_GET['nonce']);
    $salt = esc_attr($_GET['salt']);
    $user = esc_attr($_GET['user']);
    $hash = base64_encode(hash('sha256', $nonce . $salt, false));
    $hash = substr($hash, 0, 64);
    if (get_transient('sso_token') == $hash) {
        if (is_email($user)) {
            $user = get_user_by('email', $user);
        } else {
            $user = get_user_by('id', (int) $user);
        }
        if (is_a($user, 'WP_User')) {
            wp_set_current_user($user->ID, $user->user_login);
            wp_set_auth_cookie($user->ID);
            do_action('wp_login', $user->user_login);
            delete_transient('sso_token');
            wp_safe_redirect(admin_url());
        } else {
            sso_req_login();
        }
    } else {
        sso_add_failed_attempt();
        sso_req_login();
    }
    die;
}
开发者ID:annbransom,项目名称:techishowl_prod_backup,代码行数:41,代码来源:sso.php


示例14: action

 /**
  * Generates token.
  *
  * Uses 'create_token' to create a token.
  *
  * @since 4.3.0
  *
  * @param string $request The rest-api request that contains all parameters.
  * @return array The token and expiration-timestamp
  */
 function action(WP_REST_Request $request)
 {
     $return = new WP_Error('400', __('Authentication failed.', 'wp_jwt_auth'));
     if (isset($request['method'])) {
         // if user wants to login by social-media-account
         $return = apply_filters('wak_login_method_' . $request['method'], $return, $request);
     } else {
         // if user wants to login by username/password
         $username = $request['username'];
         $password = $request['password'];
         $jwt_functions = new WAK_Functions();
         $user = get_user_by('login', $username);
         if ($user && wp_check_password($password, $user->data->user_pass, $user->ID)) {
             $return = $jwt_functions->create_token($user->ID);
         } else {
             $return = new WP_Error('credentials_invalid', __('Username/Password combination is invalid', 'wp_jwt_auth'));
         }
     }
     if (isset($request['set_wp_cookie']) && $request['set_wp_cookie'] == 'true' && !is_wp_error($return)) {
         wp_set_auth_cookie($return['userid'], true);
     }
     if (isset($request['redirect_to']) && !is_wp_error($return)) {
         $location = $request['redirect_to'];
         if (is_wp_error($return)) {
             $location .= '?error=true&msg=' . urlencode($return->get_error_message());
         }
         wp_redirect($location);
         exit;
         return;
     }
     return $return;
 }
开发者ID:YanikPei,项目名称:wp-jwt-authentication,代码行数:42,代码来源:class-wak-login-endpoint.php


示例15: qq_oauth

function qq_oauth()
{
    $code = $_GET['code'];
    $token_url = "https://graph.qq.com/oauth2.0/token?client_id=" . QQ_APPID . "&client_secret=" . QQ_APPSECRET . "&grant_type=authorization_code&redirect_uri=" . urlencode(home_url()) . "&code=" . $code;
    $response = wp_remote_get($token_url);
    $response = $response['body'];
    if (strpos($response, "callback") !== false) {
        wp_redirect(home_url());
    }
    $params = array();
    parse_str($response, $params);
    $qq_access_token = $params["access_token"];
    $graph_url = "https://graph.qq.com/oauth2.0/me?access_token=" . $qq_access_token;
    $str = wp_remote_get($graph_url);
    $str = $str['body'];
    if (strpos($str, "callback") !== false) {
        $lpos = strpos($str, "(");
        $rpos = strrpos($str, ")");
        $str = substr($str, $lpos + 1, $rpos - $lpos - 1);
    }
    $user = json_decode($str, true);
    if (isset($user->error)) {
        echo "<h3>错误代码:</h3>" . $user->error;
        echo "<h3>信息  :</h3>" . $user->error_description;
        exit;
    }
    $qq_openid = $user['openid'];
    if (!$qq_openid) {
        wp_redirect(home_url());
        exit;
    }
    $get_user_info = "https://graph.qq.com/user/get_user_info?" . "access_token=" . $qq_access_token . "&oauth_consumer_key=" . QQ_APPID . "&openid=" . $qq_openid . "&format=json";
    $data = wp_remote_get($get_user_info);
    $data = $data['body'];
    $data = json_decode($data, true);
    $username = $data['nickname'];
    $avatar = $data['figureurl_2'];
    if (is_user_logged_in()) {
        $this_user = wp_get_current_user();
        update_user_meta($this_user->ID, "qq_openid", $qq_openid);
        update_user_meta($this_user->ID, "qq_avatar", $avatar);
        fa_qq_oauth_redirect();
    } else {
        $user_qq = get_users(array("meta_key " => "qq_openid", "meta_value" => $qq_openid));
        if (is_wp_error($user_qq) || !count($user_qq)) {
            $login_name = wp_create_nonce($qq_openid);
            $random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
            $userdata = array('user_login' => $login_name, 'display_name' => $username, 'user_pass' => $random_password, 'nick_name' => $username);
            $user_id = wp_insert_user($userdata);
            wp_signon(array("user_login" => $login_name, "user_password" => $random_password), false);
            update_user_meta($user_id, "qq_openid", $qq_openid);
            update_user_meta($user_id, "qq_avatar", $avatar);
            fa_qq_oauth_redirect();
        } else {
            wp_set_auth_cookie($user_qq[0]->ID);
            update_user_meta($user_qq[0]->ID, "qq_avatar", $avatar);
            fa_qq_oauth_redirect();
        }
    }
}
开发者ID:yarec,项目名称:wp-oauth,代码行数:60,代码来源:auth-qq.php


示例16: my_auto_login

function my_auto_login($fields)
{
    /** if you want to send confirmation email the user */
    require_once WPMEM_PATH . '/wp-members-email.php';
    wpmem_inc_regemail($fields['ID'], $fields['password'], WPMEM_MOD_REG);
    /** notify admin of new reg, remove if not notifying admin */
    $wpmem_fields = get_option('wpmembers_fields');
    //wpmem_notify_admin( $fields['ID'], $wpmem_fields );
    /** assemble login credentials */
    $creds = array();
    $creds['user_login'] = $fields['username'];
    $creds['user_password'] = $fields['password'];
    $creds['remember'] = true;
    /** wp_signon the user and get the $user object */
    $user = wp_signon($creds, false);
    /** if no error, user is a valid signon. continue */
    if (!is_wp_error($user)) {
        /** set the auth cookie */
        wp_set_auth_cookie($fields['ID'], true);
        /** and do the redirect */
        wp_redirect($fields['wpmem_reg_url']);
        /** wp_redirect requires us to exit() */
        exit;
    }
}
开发者ID:jamessun,项目名称:assist-portal,代码行数:25,代码来源:functions.php


示例17: login

 static function login()
 {
     if (!isset($_POST[Kanban_Utils::get_nonce()]) || !wp_verify_nonce($_POST[Kanban_Utils::get_nonce()], 'login')) {
         return;
     }
     $user_by_email = get_user_by_email($_POST['email']);
     if (empty($user_by_email)) {
         Kanban::$instance->flash->add('danger', 'Whoops! We can\'t find an account for that email address.');
         wp_redirect($_POST['_wp_http_referer']);
         exit;
     }
     $creds = array();
     $creds['user_login'] = $user_by_email->user_login;
     $creds['user_password'] = $_POST['password'];
     $creds['remember'] = true;
     $user = wp_signon($creds, false);
     if (is_wp_error($user)) {
         Kanban::$instance->flash->add('danger', 'Whoops! That password is incorrect for this email address.');
         wp_redirect($_POST['_wp_http_referer']);
         exit;
     }
     wp_set_current_user($user->ID);
     wp_set_auth_cookie($user->ID);
     wp_redirect(sprintf('/%s/board', Kanban::$slug));
     exit;
 }
开发者ID:vlood,项目名称:kanban-wordpress-plugin,代码行数:26,代码来源:class-user.php


示例18: do_signin_content_user

 public static function do_signin_content_user($user_name, $password)
 {
     $login_data = array();
     $login_data['user_login'] = $user_name;
     $login_data['user_password'] = $password;
     // 1. Verify that the user name exists in the system
     $user_party_data = EntityAPI::get_by_field('party', 'user_name', $user_name);
     if (!isset($user_party_data['id'])) {
         return EntityAPIUtils::init_error($login_data, 'Invalid username or password. Please try again');
     }
     // 2. Ensure the account is active
     $profile_data = EntityAPI::get_by_field('partyprofile', 'profile_party', $user_party_data['id']);
     if (!isset($profile_data['id'])) {
         return EntityAPIUtils::init_error($user_party_data, 'Profile not found');
     }
     if ($profile_data['profile_status'] != 'A') {
         return EntityAPIUtils::init_error($user_party_data, 'You account has been deactivated please contact support on ' . get_option('cp_notify_accounts'));
     }
     $user_verify = wp_signon($login_data, true);
     if (is_wp_error($user_verify)) {
         return EntityAPIUtils::init_error($login_data, 'Invalid username or password. Please try again');
     }
     wp_set_current_user($user_verify->ID);
     wp_set_auth_cookie($user_verify->ID);
     // Build the return
     $content_user = array('user_login' => $user_name, 'user_password' => $password);
     // Process redirect
     if (isset($_POST['redirect_to'])) {
         $content_user['redirect_url'] = $_POST['redirect_to'];
     }
     return array('has_errors' => false, 'content_user' => $content_user);
 }
开发者ID:ebanfa,项目名称:shadow-plugin-builder,代码行数:32,代码来源:UserLoginAPI.php


示例19: login_register_user

 public static function login_register_user()
 {
     if ($_REQUEST['loginGoogle'] == '1') {
         $client = self::get_client();
         session_start();
         $oauth2 = new displetretsidx_Google_Oauth2Service($client);
         if (isset($_GET['code'])) {
             $client->authenticate($_GET['code']);
             $_SESSION['token'] = $client->getAccessToken();
         }
         if (isset($_SESSION['token'])) {
             $client->setAccessToken($_SESSION['token']);
         }
         if ($client->getAccessToken()) {
             $user = $oauth2->userinfo->get();
             // Filtered via PHP sanitize filters
             $email = filter_var($user['email'], FILTER_SANITIZE_EMAIL);
             global $displetretsidx_event_tracking_email;
             $displetretsidx_event_tracking_email = $email;
             $user_id = DispletRetsIdxUsersModel::get_user_id_by_email($email);
             if (!empty($user_id)) {
                 wp_set_auth_cookie($user_id, true);
                 add_action('login_head', array('DispletRetsIdxGoogleLoginController', 'include_login_event_tracking_code'), 999999999999);
             } else {
                 $user_registration_response = DispletRetsIdxLeadsController::create_new_re_search_user(array('email' => $email, 'name' => $user['name'], 'phone' => 'Google', 'url' => $_COOKIE['displet_registration_url'], 'upstream_url' => $_COOKIE['displet_upstream_url'], 'last_hash' => $_COOKIE['displetretsidx_last_viewed_hash']));
                 if (!empty($user_registration_response['success'])) {
                     add_action('login_head', array('DispletRetsIdxGoogleLoginController', 'include_registration_event_tracking_code'), 999999999999);
                 }
             }
         }
     }
 }
开发者ID:amankatoch,项目名称:wp-plugin,代码行数:32,代码来源:class-displet-rets-idx-google-login-controller.php


示例20: otl_authenticate_one_time_login

/**
 * Process one time login
 *
 * @since  1.0.0
 *
 * @return void
 */
function otl_authenticate_one_time_login()
{
    // No need to run if not a singular query for the one time login
    if (!is_single()) {
        return;
    }
    // No need to run if not a onetimelogin post
    global $post;
    if ('onetimelogin' !== $post->post_type) {
        return;
    }
    $user_id = get_post_meta(get_the_ID(), 'otl_user', true);
    $valid_user = get_userdata($user_id) ? true : false;
    $login_uses = get_post_meta(get_the_ID(), 'otl_times_used', true);
    // If the one time login is unused and the user is valid, log in
    if ('0' === $login_uses && $valid_user) {
        // Log in
        wp_clear_auth_cookie();
        wp_set_current_user($user_id);
        wp_set_auth_cookie($user_id);
        // Update some meta for logging and to prevent multiple uses
        update_post_meta(get_the_ID(), 'otl_times_used', '1');
        update_post_meta(get_the_ID(), 'otl_datetime_used', current_time('mysql'));
        // Redirect to wp-admin
        wp_safe_redirect(user_admin_url());
        exit;
    } else {
        wp_redirect(home_url());
        exit;
    }
    return;
}
开发者ID:ryanduff,项目名称:one-time-login,代码行数:39,代码来源:login-handler.php



注:本文中的wp_set_auth_cookie函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP wp_set_comment_status函数代码示例发布时间:2022-05-23
下一篇:
PHP wp_set_all_user_settings函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap