Analysis of WordPress Control user Login and judge user login PHP function, wordpress user Login _php Tutorial

Source: Internet
Author: User

To parse the PHP function that controls user login and judge user login in wordpress, wordpress user Login


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.

Articles you may be interested in:

    • WordPress to close the landing page after landing and set the user not visible columns
    • WordPress in the guest login to implement email alerts PHP Script instance sharing

http://www.bkjia.com/PHPjc/1105377.html www.bkjia.com true http://www.bkjia.com/PHPjc/1105377.html techarticle Parse WordPress Control user Login and judge user login PHP function, wordpress user Login Login function: Wp_signon () function Description: Wp_signon () function is used to authorize the user login ...

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.