LLMS_Person_Handler::login( array $data )
Login a user
Parameters Parameters
- $data
-
(array) (Required) User login information.
- 'llms_login'
(string) User email address or username. - 'llms_password'
(string) User password. - 'llms_remember'
(string) Whether to extend the cookie duration to keep the user logged in for a longer period.
- 'llms_login'
Return Return
(WP_Error|int) The WP_User ID on login success or an error object on failure.
Source Source
File: includes/class.llms.person.handler.php
public static function login( $data ) { /** * Run an action prior to user login. * * @since 3.0.0 * * @param array $data { * User login credentials. * * @type string $user_login User's username. * @type string $password User's password. * @type bool $remeber Whether to extend the cookie duration to keep the user logged in for a longer period. * } */ do_action( 'lifterlms_before_user_login', $data ); /** * Filter user submitted login data prior to data validation. * * @since 3.0.0 * * @param array $data { * User login credentials. * * @type string $user_login User's username. * @type string $password User's password. * @type bool $remeber Whether to extend the cookie duration to keep the user logged in for a longer period. * } */ $data = apply_filters( 'lifterlms_user_login_data', $data ); // Validate the fields & allow custom validation to occur. $valid = self::validate_login_fields( $data ); // If errors found, return them. if ( is_wp_error( $valid ) ) { /** * Filters the errors found during a LifterLMS user login attempt * * @since Unknown * * @param WP_Error $valid Error object containing information about the login error. * @param array $data User submitted login form data. * @param WP_Error|false $signon The original WP Error object returned by `wp_signon()` or false if the error * is encountered prior to the signon attempt. */ return apply_filters( 'lifterlms_user_login_errors', $valid, $data, false ); } $creds = array( 'user_login' => wp_unslash( $data['llms_login'] ), // Unslash ensures that an email address with an apostrophe is unescaped for lookups. 'user_password' => $data['llms_password'], 'remember' => isset( $data['llms_remember'] ), ); /** * Filter a user's login credentials immediately prior to signing in. * * @since Unknown * * @param array $creds { * User login credentials. * * @type string $user_login User's username. * @type string $password User's password. * @type bool $remeber Whether to extend the cookie duration to keep the user logged in for a longer period. * } */ $creds = apply_filters( 'lifterlms_login_credentials', $creds ); $signon = wp_signon( $creds, is_ssl() ); if ( is_wp_error( $signon ) ) { $err = new WP_Error( 'login-error', __( 'Could not find an account with the supplied email address and password combination.', 'lifterlms' ) ); // This hook is documented in includes/class.llms.person.handler.php. return apply_filters( 'lifterlms_user_login_errors', $err, $data, $signon ); } return $signon->ID; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.0.0 | Removed email lookup logic since wp_authenticate() supports email addresses as user_login since WP 4.5. |
3.29.4 | Unknown. |
3.0.0 | Introduced. |