WP_REST_Comments_Controller::check_comment_author_email( string $value, WP_REST_Request $request, string $param ): string|WP_Error

Checks a comment author email for validity.

Description

Accepts either a valid email address or empty string as a valid comment author email address. Setting the comment author email to an empty string is allowed when a comment is being updated.

Parameters

$valuestringrequired
Author email value submitted.
$requestWP_REST_Requestrequired
Full details about the request.
$paramstringrequired
The parameter name.

Return

string|WP_Error The sanitized email address, if valid, otherwise an error.

Source

public function check_comment_author_email( $value, $request, $param ) {
	$email = (string) $value;
	if ( empty( $email ) ) {
		return $email;
	}

	$check_email = rest_validate_request_arg( $email, $request, $param );
	if ( is_wp_error( $check_email ) ) {
		return $check_email;
	}

	return $email;
}

Changelog

VersionDescription
4.7.0Introduced.

User Contributed Notes

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