LLMS_Form_Validator::validate_field_user_login( string $posted_value )
Validate a user-login field
Description Description
Ensures that a username isn’t found in the LifterLMS username blocklist, that it meets the default WP core username criteria and that the username doesn’t already exist.
Parameters Parameters
- $posted_value
-
(string) (Required) User-submitted (dirty) value.
Return Return
(WP_Error|boolean) Returns true
for a valid submission, otherwise an error.
Source Source
File: includes/forms/class-llms-form-validator.php
protected function validate_field_user_login( $posted_value ) { if ( in_array( $posted_value, llms_get_usernames_blocklist(), true ) || ! validate_username( $posted_value ) ) { return new WP_Error( 'llms-form-field-invalid', sprintf( __( 'The username "%s" is invalid, please try a different username.', 'lifterlms' ), $posted_value ), $posted_value ); } elseif ( username_exists( $posted_value ) ) { return new WP_Error( 'llms-form-field-not-unique', sprintf( __( 'An account with the username "%s" already exists.', 'lifterlms' ), $posted_value ), $posted_value ); } return true; }
Expand full source code Collapse full source code View on GitHub
Changelog Changelog
Version | Description |
---|---|
5.0.0 | Introduced. |