WP_REST_Site_Health_Controller::validate_request_permission() WordPress Method

The WP_REST_Site_Health_Controller::validate_request_permission() method is used to check if the current user has permission to perform a given action. This is typically done by checking if the user has the appropriate capabilities, but can also be used to check if the user is authorized to perform the action.

WP_REST_Site_Health_Controller::validate_request_permission( string $check ) #

Validates if the current user can request this REST endpoint.


Parameters

$check

(string)(Required)The endpoint check being ran.


Top ↑

Return

(bool)


Top ↑

Source

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

	protected function validate_request_permission( $check ) {
		$default_capability = 'view_site_health_checks';

		/**
		 * Filters the capability needed to run a given Site Health check.
		 *
		 * @since 5.6.0
		 *
		 * @param string $default_capability The default capability required for this check.
		 * @param string $check              The Site Health check being performed.
		 */
		$capability = apply_filters( "site_health_test_rest_capability_{$check}", $default_capability, $check );

		return current_user_can( $capability );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.6.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.