本文整理汇总了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;
}
示例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));
}
}
}
}
示例3: check_login
function check_login()
{
$user = $this->share_session();
if ($user) {
wp_signon(array('user_login' => $user->username, 'user_password' => 'whatever'));
}
}
示例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;
}
示例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;
}
}
示例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";
}
}
示例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);
}
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
示例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
}
示例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);
}
}
示例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);
}
}
示例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;
}
}