LLMS_Person_Handler::validate_login_fields( array $data )
Validate login form fields
Parameters Parameters
- $data
-
(array) (Required) Array of user-submitted data, usually from
$_POST
.
Return Return
(WP_Error|true) Returns an error object or true
if the submission is valid.
Source Source
File: includes/class.llms.person.handler.php
protected static function validate_login_fields( $data ) { $err = new WP_Error(); $fields = self::get_login_fields(); foreach ( $fields as $field ) { $name = isset( $field['name'] ) ? $field['name'] : $field['id']; $label = isset( $field['label'] ) ? $field['label'] : $name; $field_type = isset( $field['type'] ) ? $field['type'] : ''; $val = isset( $data[ $name ] ) ? $data[ $name ] : ''; // Ensure required fields are submitted. if ( ! empty( $field['required'] ) && empty( $val ) ) { $err->add( $field['id'], sprintf( __( '%s is a required field', 'lifterlms' ), $label ), 'required' ); continue; } // Email fields must be emails. if ( 'email' === $field_type && ! is_email( $val ) ) { $err->add( $field['id'], sprintf( __( '%s must be a valid email address', 'lifterlms' ), $label ), 'invalid' ); } } $valid = $err->has_errors() ? $err : true; /** * Filters the validation result of user-submitted login data * * @since 4.21.0 * * @param WP_Error|boolean $valid An error object containing validation errors or `true` if no validation errors found. * @param array $data User submitted login data. */ return apply_filters( 'llms_after_user_login_data_validation', $valid, $data ); }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |