wp_signon [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Authenticate user with remember capability.
The credentials is an array that has 'user_login', 'user_password', and 'remember' indices. If the credentials is not given, then the log in form will be assumed and used if set.
The various authentication cookies will be set by this function and will be set for a longer period depending on if the 'remember' credential is set to true.
Source
<?php
function wp_signon( $credentials = '', $secure_cookie = '' ) {
if ( empty($credentials) ) {
if ( ! empty($_POST['log']) )
$credentials['user_login'] = $_POST['log'];
if ( ! empty($_POST['pwd']) )
$credentials['user_password'] = $_POST['pwd'];
if ( ! empty($_POST['rememberme']) )
$credentials['remember'] = $_POST['rememberme'];
}
if ( !empty($credentials['remember']) )
$credentials['remember'] = true;
else
$credentials['remember'] = false;
// TODO do we deprecate the wp_authentication action?
do_action_ref_array('wp_authenticate', array(&$credentials['user_login'], &$credentials['user_password']));
if ( '' === $secure_cookie )
$secure_cookie = is_ssl();
$secure_cookie = apply_filters('secure_signon_cookie', $secure_cookie, $credentials);
global $auth_secure_cookie; // XXX ugly hack to pass this to wp_authenticate_cookie
$auth_secure_cookie = $secure_cookie;
add_filter('authenticate', 'wp_authenticate_cookie', 30, 3);
$user = wp_authenticate($credentials['user_login'], $credentials['user_password']);
if ( is_wp_error($user) ) {
if ( $user->get_error_codes() == array('empty_username', 'empty_password') ) {
$user = new WP_Error('', '');
}
return $user;
}
wp_set_auth_cookie($user->ID, $credentials['remember'], $secure_cookie);
do_action('wp_login', $user->user_login, $user);
return $user;
}
?>
Examples [ wp-snippets.com ]
Google Arama Sonuçlarý
- Function Reference/wp signon « WordPress Codex
Description. Authenticates a user with option to remember credentials. Replaces deprecated function wp_login. Usage. <?php wp_signon( $credentials ...
codex.wordpress.org - wordpress wp_signon function not working - Stack Overflow
I am using wp_signon() function to login the user. I am doing this like ... wp_signon() needs to run before you've sent any of your actual page to ...
stackoverflow.com - WordPress: wp_signon() – $current_user is not populated
When using the WordPress wp_signon() function the global user variables such as $current_user and $user_ID don't get populated until after the page has ...
blog.rhysgoodwin.com - login - wp_signon returns user, but the user is not logged in ...
Nov 4, 2010 ... After using wp_signon() , the user info is not set, which is how WP checks for a user in is_user_logged_in() . It should be just a matter of calling ...
wordpress.stackexchange.com
Kullanýcý Tartýþmalarý [ wordpress.org ]
- martin11ph on "wp_signon auto login fails"
- martin11ph on "wp_signon auto login fails"
- martin11ph on "wp_signon auto login fails"
- mrismail on "logging a user in using an ajax request"
- Charles Leonard on "Custom Log In, request for reauth on wp-admin"
- RobinWellner on "Custom Log In, request for reauth on wp-admin"
- Charles Leonard on "Custom Log In, request for reauth on wp-admin"
- Charles Leonard on "Custom Log In, request for reauth on wp-admin"
- matlin on "wp_signon doesn't give error with wrong password"
- kmessinger on "wp_signon doesn't give error with wrong password"