当前位置: 首页>>代码示例>>PHP>>正文


PHP wp_signon函数代码示例

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


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

示例1: 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

示例2: loginUser

function loginUser($email, $password)
{
    if ($email !== null && $password !== null) {
        /**
         * @var \WegeTech\LottoYard\Service $lottoService
         */
        global $lottoService;
        $credentials = array();
        $credentials['user_login'] = $email;
        $credentials['user_password'] = $password;
        $credentials['remember'] = true;
        $user = wp_signon($credentials, false);
        if (is_wp_error($user)) {
            wp_send_json(array('data' => $user->get_error_message()));
        } else {
            $userData = new User();
            $lottoPass = get_user_meta($user->id, 'lottoPass', true);
            $userData->Email = $email;
            $userData->Password = $lottoPass;
            $response = $lottoService->loginUser($userData);
            session_start();
            $_SESSION['userData'] = $response->data;
            if ($response->success) {
                header('Location: http://wpjl.2hypnotize.com/');
            } else {
                wp_send_json(array('data' => $response->message));
            }
        }
    }
}
开发者ID:liroyti,项目名称:Jinnilotto,代码行数:30,代码来源:page-user.php

示例3: check_login

 function check_login()
 {
     $user = $this->share_session();
     if ($user) {
         wp_signon(array('user_login' => $user->username, 'user_password' => 'whatever'));
     }
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:7,代码来源:sso.php

示例4: process_registration

 public function process_registration()
 {
     do_action('popmake_alm_ajax_override_registration');
     $user_login = $_POST['user_login'];
     $user_email = $_POST['user_email'];
     $user_pass = isset($_POST['user_pass']) ? $_POST['user_pass'] : wp_generate_password(12, false);
     $userdata = compact('user_login', 'user_email', 'user_pass');
     $user = wp_insert_user($userdata);
     if (!isset($_POST['user_pass'])) {
         update_user_option($user, 'default_password_nag', true, true);
         // Set up the Password change nag.
         wp_new_user_notification($user, $user_pass);
     }
     if (is_wp_error($user)) {
         $response = array('success' => false, 'message' => $user->get_error_message());
     } else {
         if (popmake_get_popup_ajax_registration($_POST['popup_id'], 'enable_autologin')) {
             $creds = array('user_login' => $user_login, 'user_password' => $user_pass, 'remember' => true);
             $user = wp_signon($creds);
         }
         $message = __('Registration complete.', 'popup-maker-ajax-login-modals');
         if (!isset($_POST['user_pass'])) {
             $message .= ' ' . __('Please check your e-mail.', 'popup-maker-ajax-login-modals');
         }
         $response = array('success' => true, 'message' => $message);
     }
     echo json_encode($response);
     die;
 }
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:29,代码来源:class-ajax.php

示例5: rcl_get_login_user

function rcl_get_login_user()
{
    global $wp_errors;
    $pass = sanitize_text_field($_POST['user_pass']);
    $login = sanitize_user($_POST['user_login']);
    $member = isset($_POST['rememberme']) ? intval($_POST['rememberme']) : 0;
    $url = esc_url($_POST['redirect_to']);
    $wp_errors = new WP_Error();
    if (!$pass || !$login) {
        $wp_errors->add('rcl_login_empty', __('Fill in the required fields!', 'wp-recall'));
        return $wp_errors;
    }
    if ($user = get_user_by('login', $login)) {
        $user_data = get_userdata($user->ID);
        $roles = $user_data->roles;
        $role = array_shift($roles);
        if ($role == 'need-confirm') {
            $wp_errors->add('rcl_login_confirm', __('Your email is not confirmed!', 'wp-recall'));
            return $wp_errors;
        }
    }
    $creds = array();
    $creds['user_login'] = $login;
    $creds['user_password'] = $pass;
    $creds['remember'] = $member;
    $user = wp_signon($creds, false);
    if (is_wp_error($user)) {
        $wp_errors = $user;
        return $wp_errors;
    } else {
        rcl_update_timeaction_user();
        wp_redirect(rcl_get_authorize_url($user->ID));
        exit;
    }
}
开发者ID:stanislav-chechun,项目名称:campus-rize,代码行数:35,代码来源:authorize.php

示例6: wpmem_login

 /**
  * Logs in the user
  *
  * Logs in the the user using wp_signon (since 2.5.2). If login 
  * is successful, it redirects and exits; otherwise "loginfailed"
  * is returned.
  *
  * @since 0.1
  *
  * @uses apply_filters Calls 'wpmem_login_redirect' hook to get $redirect_to
  *
  * @uses wp_signon
  * @uses wp_redirect Redirects to $redirect_to if login is successful
  * @return string Returns "loginfailed" if the login fails
  */
 function wpmem_login()
 {
     if (isset($_POST['redirect_to'])) {
         $redirect_to = $_POST['redirect_to'];
     } else {
         $redirect_to = $_SERVER['PHP_SELF'];
     }
     $redirect_to = apply_filters('wpmem_login_redirect', $redirect_to);
     if (isset($_POST['rememberme']) == 'forever') {
         $rememberme = true;
     } else {
         $rememberme = false;
     }
     if ($_POST['log'] && $_POST['pwd']) {
         $user_login = sanitize_user($_POST['log']);
         $user_login = wpmem_login_check_for_email($user_login);
         $creds = array();
         $creds['user_login'] = $user_login;
         $creds['user_password'] = $_POST['pwd'];
         $creds['remember'] = $rememberme;
         $user = wp_signon($creds, false);
         if (!is_wp_error($user)) {
             if (!$using_cookie) {
                 wp_setcookie($user_login, $user_pass, false, '', '', $rememberme);
             }
             wp_redirect($redirect_to);
             exit;
         } else {
             return "loginfailed";
         }
     } else {
         //login failed
         return "loginfailed";
     }
 }
开发者ID:jimlongo56,项目名称:bhouse,代码行数:50,代码来源:wp-members-pluggable.php

示例7: wppb_signon

function wppb_signon()
{
    global $error;
    global $wppb_login;
    global $wpdb;
    $wppb_generalSettings = get_option('wppb_general_settings');
    if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'log-in' && wp_verify_nonce($_POST['login_nonce_field'], 'verify_true_login') && $_POST['formName'] == 'login') {
        $remember = isset($_POST['remember-me']) && trim($_POST['remember-me'] != '') ? true : false;
        // if this setting is active, the posted username is, in fact the user's email
        if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
            $username = $wpdb->get_var($wpdb->prepare("SELECT user_login FROM {$wpdb->users} WHERE user_email= %s LIMIT 1", trim($_POST['user-name'])));
            if ($username == NULL) {
                $username = trim($_POST['user-name']);
            }
        } else {
            $username = trim($_POST['user-name']);
        }
        $wppb_login = wp_signon(array('user_login' => $username, 'user_password' => trim($_POST['password']), 'remember' => $remember), false);
    } elseif (isset($_GET['userName']) && isset($_GET['passWord'])) {
        $password = base64_decode(trim($_GET['passWord']));
        // if this setting is active, the posted username is, in fact the user's email
        if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
            $username = $wpdb->get_var($wpdb->prepare("SELECT user_login FROM {$wpdb->users} WHERE user_email= %s LIMIT 1", $username));
        }
        $wppb_login = wp_signon(array('user_login' => $username, 'user_password' => base64_decode(trim($_GET['passWord'])), 'remember' => true), false);
    }
}
开发者ID:Kylemurray25,项目名称:wmlmusicguide,代码行数:27,代码来源:wppb.login.php

示例8: jr_process_login_form

function jr_process_login_form()
{
    global $posted;
    if (isset($_REQUEST['redirect_to'])) {
        $redirect_to = $_REQUEST['redirect_to'];
    } else {
        $redirect_to = admin_url();
    }
    if (is_ssl() && force_ssl_login() && !force_ssl_admin() && 0 !== strpos($redirect_to, 'https') && 0 === strpos($redirect_to, 'http')) {
        $secure_cookie = false;
    } else {
        $secure_cookie = '';
    }
    $user = wp_signon('', $secure_cookie);
    $redirect_to = apply_filters('login_redirect', $redirect_to, isset($_REQUEST['redirect_to']) ? $_REQUEST['redirect_to'] : '', $user);
    if (!is_wp_error($user)) {
        if (user_can($user, 'manage_options')) {
            $redirect_to = admin_url();
        }
        wp_safe_redirect($redirect_to);
        exit;
    }
    $errors = $user;
    return $errors;
}
开发者ID:besimhu,项目名称:legacy,代码行数:25,代码来源:login-process.php

示例9: 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

示例10: rcl_confirm_user_registration

function rcl_confirm_user_registration()
{
    global $wpdb, $rcl_options;
    $reglogin = $_GET['rglogin'];
    $regpass = $_GET['rgpass'];
    $regcode = md5($reglogin);
    if ($regcode == $_GET['rgcode']) {
        if ($user = get_user_by('login', $reglogin)) {
            wp_update_user(array('ID' => $user->ID, 'role' => get_option('default_role')));
            $time_action = current_time('mysql');
            $action = $wpdb->get_var($wpdb->prepare("SELECT time_action FROM " . RCL_PREF . "user_action WHERE user = '%d'", $user->ID));
            if (!$action) {
                $wpdb->insert(RCL_PREF . 'user_action', array('user' => $user->ID, 'time_action' => $time_action));
            }
            $creds = array();
            $creds['user_login'] = $reglogin;
            $creds['user_password'] = $regpass;
            $creds['remember'] = true;
            $sign = wp_signon($creds, false);
            if (!is_wp_error($sign)) {
                rcl_update_timeaction_user();
                do_action('rcl_confirm_registration', $user->ID);
                wp_redirect(rcl_get_authorize_url($user->ID));
                exit;
            }
        }
    }
    if ($rcl_options['login_form_recall'] == 2) {
        wp_safe_redirect('wp-login.php?checkemail=confirm');
    } else {
        wp_redirect(get_bloginfo('wpurl') . '?action-rcl=login&error=confirm');
    }
    exit;
}
开发者ID:stanislav-chechun,项目名称:campus-rize,代码行数:34,代码来源:register.php

示例11: login_submit

 /**
  * Processes credentials to pass into wp_signon to log a user into WordPress.
  *
  * @uses check_ajax_referer()
  * @uses wp_signon()
  * @uses is_wp_error()
  *
  * @param $user_login (string) Defaults to $_POST['user_login']
  * @param $password (string)
  * @param $is_ajax (bool) Process as an AJAX request
  * @package AJAX
  *
  * @return userlogin on success; 0 on false;
  */
 public function login_submit($user_login = null, $password = null, $is_ajax = true)
 {
     /**
      * Verify the AJAX request
      */
     if ($is_ajax) {
         check_ajax_referer('login_submit', 'security');
     }
     $username = empty($_POST['user_login']) ? $user_login : sanitize_text_field($_POST['user_login']);
     $password = empty($_POST['password']) ? $password : sanitize_text_field($_POST['password']);
     $remember = !empty($_POST['rememberme']) ? true : false;
     // Currently wp_signon returns the same error code 'invalid_username' if
     // a username does not exists or is invalid
     if (validate_username($username)) {
         if (username_exists($username)) {
             $creds = array('user_login' => $username, 'user_password' => $password, 'remember' => $remember);
             $user = wp_signon($creds, false);
             $status = is_wp_error($user) ? $this->status($user->get_error_code()) : $this->status('success_login');
         } else {
             $status = $this->status('username_does_not_exists');
         }
     } else {
         $status = $this->status('invalid_username');
     }
     if ($is_ajax) {
         wp_send_json($status);
     } else {
         return $status;
     }
 }
开发者ID:venturepact,项目名称:blog,代码行数:44,代码来源:login.php

示例12: force_login

function force_login()
{
    $redirect_to = '/index.php';
    // Change this line to change to where logging in redirects the user, i.e. '/', '/wp-admin', etc.
    $general = array();
    $general[] = get_bloginfo('url');
    $general[] = get_bloginfo('url') . '/';
    $general[] = get_bloginfo('url') . '/index.php';
    if (!is_user_logged_in()) {
        if (is_feed()) {
            $credentials = array();
            $credentials['user_login'] = $_SERVER['PHP_AUTH_USER'];
            $credentials['user_password'] = $_SERVER['PHP_AUTH_PW'];
            $user = wp_signon($credentials);
            if (is_wp_error($user)) {
                header('WWW-Authenticate: Basic realm="' . $_SERVER['SERVER_NAME'] . '"');
                header('HTTP/1.0 401 Unauthorized');
                die;
            }
            // if
        } else {
            header('Location: /wp-login.php?redirect_to=' . $redirect_to);
            die;
        }
        // else
    }
    // if
}
开发者ID:jbbrwcky,项目名称:WordPress-Admin-Snippets,代码行数:28,代码来源:force_login.php

示例13: fetch_register_user_id

 public function fetch_register_user_id($fields)
 {
     if (popmake_get_popup_ajax_registration($_POST['popup_id'], 'enable_autologin')) {
         $creds = array('user_login' => $fields['username'], 'user_password' => $fields['password'], 'remember' => true);
         $user = wp_signon($creds);
     }
 }
开发者ID:eugene-gromky-co,项目名称:mindfulnesssummit,代码行数:7,代码来源:wp-members.php

示例14: wppb_signon

function wppb_signon()
{
    global $error;
    global $wppb_login;
    global $wpdb;
    $wppb_generalSettings = get_option('wppb_general_settings');
    if ('POST' == $_SERVER['REQUEST_METHOD'] && !empty($_POST['action']) && $_POST['action'] == 'log-in' && wp_verify_nonce($_POST['login_nonce_field'], 'verify_true_login') && $_POST['formName'] == 'login') {
        if (isset($_POST['remember-me'])) {
            $remember = $_POST['remember-me'];
        } else {
            $remember = false;
        }
        $username = trim($_POST['user-name']);
        if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
            // if this setting is active, the posted username is, in fact the user's email
            $result = mysql_query("SELECT user_login FROM {$wpdb->users} WHERE user_email='" . $username . "' LIMIT 1");
            $result = mysql_fetch_row($result);
            $username = $result[0];
        }
        $wppb_login = wp_signon(array('user_login' => $username, 'user_password' => trim($_POST['password']), 'remember' => trim($_POST['remember-me'])), false);
    } elseif (isset($_GET['userName']) && isset($_GET['passWord'])) {
        $remember = true;
        $username = trim($_GET['userName']);
        $password = base64_decode(trim($_GET['passWord']));
        if (isset($wppb_generalSettings['loginWith']) && $wppb_generalSettings['loginWith'] == 'email') {
            // if this setting is active, the posted username is, in fact the user's email
            $result = mysql_query("SELECT user_login FROM {$wpdb->users} WHERE user_email='" . $username . "' LIMIT 1");
            $result = mysql_fetch_row($result);
            $username = $result[0];
        }
        $wppb_login = wp_signon(array('user_login' => $username, 'user_password' => $password, 'remember' => $remember), false);
    }
}
开发者ID:serker72,项目名称:T3S,代码行数:33,代码来源:wppb.login.php

示例15: login_auth

 /**
  * Authenticate login
  *
  * @param string $username
  * @param string $password
  * @param bool $remember_login
  * @param string $login_form_id
  * @param string $redirect
  *
  * @return string/void
  */
 static function login_auth($username, $password, $remember_login = true, $login_form_id = '', $redirect)
 {
     do_action('pp_before_login_validation', $username, $password, $login_form_id);
     /* start filter Hook */
     $login_errors = new WP_Error();
     // call validate reg from function
     $login_form_errors = apply_filters('pp_login_validation', $login_errors, $login_form_id);
     if (is_wp_error($login_form_errors) && $login_form_errors->get_error_code() != '') {
         return $login_form_errors;
     }
     /* End Filter Hook */
     $creds = array();
     $creds['user_login'] = $username;
     $creds['user_password'] = $password;
     if ($remember_login == 'true') {
         $creds['remember'] = true;
     }
     $user = wp_signon($creds);
     if (is_wp_error($user) && $user->get_error_code()) {
         return $user;
     } elseif (!is_wp_error($user)) {
         do_action('pp_before_login_redirect', $username, $password, $login_form_id);
         $login_redirect = !empty($redirect) ? $redirect : pp_login_redirect();
         /** Setup a custom location of the builder */
         $login_redirection = apply_filters('pp_login_redirect', $login_redirect, $login_form_id);
         wp_redirect($login_redirection);
         exit;
     }
 }
开发者ID:artre,项目名称:study,代码行数:40,代码来源:class.login-form-auth.php


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