Login function: Wp_signon ()
Function Description:
The Wp_signon () function is used to authorize users to log on to WordPress and remember the user name. This function replaces the wp_login. The WordPress 2.5 version is enabled.
function use:
Parameter description:
- $credentials
- (array) (optional) login user information.
- Default:none
- $secure _cookie
- (Boolean) (optional) Decide whether to use a security cookie.
- Default:none
Note: If you do not provide a $credentials, Wp_signon uses the $_post parameter (the key value is "log", "pwd" and "RememberMe").
function return value:
(object)
Login failed return object Wp_error, login successful return Wp_user
function instance:
$creds = Array (); $creds [' user_login '] = ' example '; Wordperss background user name $creds[' user_password '] = ' 123456 '; Wordperss Background user password $creds[' remember ' = true; $user = Wp_signon ($creds, false); if (Is_wp_error ($user)) echo $user-&G T;get_error_message ();
Source file:
Wp_signon () is located in wp-includes/user.php.
Determine if the user is logged in: is_user_logged_in ()
Function Description:
The is_user_logged_in () function returns false because it determines whether the user is logged on or not and returns true if the user has logged in.
function use:
Function parameters:
The function does not accept any arguments.
return value:
(Boolean)
Logged in returns True, otherwise false is returned.
function instance:
The following example shows what is displayed by the logged on user or the user who is not logged in:
<?phpif (is_user_logged_in ()) { echo ' Welcome, Registered user! ';} else { echo ' Welcome, visitor! ';}? >
Source file:
Is_user_logged_in () is located in the file wp-includes/pluggable.php.
The above describes the analysis of the WordPress control user login and judge the user login PHP function, including the content, I hope the PHP tutorial interested in a friend to help.