WP_REST_Comments_Controller::check_comment_author_email() WordPress Method

The WP_REST_Comments_Controller::check_comment_author_email() method is used to check whether the email address of a comment author is valid. This is a boolean method that returns true if the email address is valid, and false if it is not.

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

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.


Top ↑

Parameters

$value

(string)(Required)Author email value submitted.

$request

(WP_REST_Request)(Required)Full details about the request.

$param

(string)(Required)The parameter name.


Top ↑

Return

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


Top ↑

Source

File: wp-includes/rest-api/endpoints/class-wp-rest-comments-controller.php

	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;
	}


Top ↑

Changelog

Changelog
VersionDescription
4.7.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.