LLMS_REST_Users_Controller::sanitize_username( string $value, WP_REST_Request $request, string $param )

Validate a username is valid and allowed


Parameters Parameters

$value

(string) (Required) User-submitted username.

$request

(WP_REST_Request) (Required) Request object.

$param

(string) (Required) Parameter name.


Top ↑

Return Return

(WP_Error|string) Sanitized username if valid or error object.


Top ↑

Source Source

File: libraries/lifterlms-rest/includes/abstracts/class-llms-rest-users-controller.php

	/**
	 * Validate a username is valid and allowed
	 *
	 * @since 1.0.0-beta.1
	 *
	 * @param string          $value   User-submitted username.
	 * @param WP_REST_Request $request Request object.
	 * @param string          $param   Parameter name.
	 * @return WP_Error|string Sanitized username if valid or error object.
	 */
	public function sanitize_username( $value, $request, $param ) {

		$username = (string) $value;

		if ( ! validate_username( $username ) ) {
			return llms_rest_bad_request_error( __( 'Username contains invalid characters.', 'lifterlms' ) );
		}

		/**
		 * Filter defined in WP Core.
		 *
		 * @link  https://developer.wordpress.org/reference/hooks/illegal_user_logins/


Top ↑

Changelog Changelog

Changelog
Version Description
1.0.0-beta.1 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.