: This article describes how to parse the PHP functions used to control user login and determine user login in WordPress. For more information about PHP tutorials, see. Login function: wp_signon ()
Function introduction:
The wp_signon () function is used to authorize a user to log on to wordpress and remember the user name. This function replaces wp_login. Start WordPress 2.5.
Function usage:
<?php wp_signon( $credentials, $secure_cookie ) ?>
Parameter description:
- $ Credentials
- (Array) (optional) login user information.
- Default: None
- $ Secure_cookie
- (Boolean) (optional) determines whether to use a secure cookie.
- Default: None
Note: If you do not provide $ credentials, wp_signon uses the $ _ POST parameter (the key values are "log", "pwd", and "rememberme ").
Function return value:
(Object)
WP_Error is returned when logon fails. if logon succeeds, WP_User is returned.
Function example:
$ Creds = array (); $ creds ['User _ login'] = 'example '; // wordperss background user Name $ creds ['User _ password'] = '000000'; // wordperss background user password $ creds ['remember'] = true; $ user = wp_signon ($ creds, false); if (is_wp_error ($ user) echo $ user-> get_error_message ();
Source File:
Wp_signon () is located in wp-nodes des/user. php.
Determine whether the user logs in to the function: is_user_logged_in ()
Function introduction:
The is_user_logged_in () function determines whether a user has logged on. if the user has logged on, True is returned. otherwise, False is returned.
Function usage:
<?php if ( is_user_logged_in() ) { ... } ?>
Function parameters:
This function does not accept any parameters.
Return value:
(Boolean)
If you have logged on, True is returned. otherwise, False is returned.
Function example:
The following instances show logged-in users or unlogged-in users:
<?phpif ( is_user_logged_in() ) { echo 'Welcome, registered user!';} else { echo 'Welcome, visitor!';}?>
Source File:
Is_user_logged_in () is in the wp-uplodes/pluggable. php file.
The above describes how to parse the PHP functions used to control user login and determine user login in WordPress, including some content, and hope to help those who are interested in PHP tutorials.