wp_maybe_grant_site_health_caps() WordPress Function

The wp_maybe_grant_site_health_caps() function is used to grant the site health manager role the necessary capabilities to view and manage site health information. This function is only available in WordPress 4.9.6 and higher.

wp_maybe_grant_site_health_caps( bool[] $allcaps, string[] $caps, array $args, WP_User $user ) #

Filters the user capabilities to grant the ‘view_site_health_checks’ capabilities as necessary.


Parameters

$allcaps

(bool[])(Required)An array of all the user's capabilities.

$caps

(string[])(Required)Required primitive capabilities for the requested capability.

$args

(array)(Required)Arguments that accompany the requested capability check.

  • (string) Requested capability.
  • '1'
    (int) Concerned user ID.
  • '...$2'
    (mixed) Optional second and further parameters, typically object ID.

$user

(WP_User)(Required)The user object.


Top ↑

Return

(bool[]) Filtered array of the user's capabilities.


Top ↑

Source

File: wp-includes/capabilities.php

function wp_maybe_grant_site_health_caps( $allcaps, $caps, $args, $user ) {
	if ( ! empty( $allcaps['install_plugins'] ) && ( ! is_multisite() || is_super_admin( $user->ID ) ) ) {
		$allcaps['view_site_health_checks'] = true;
	}

	return $allcaps;
}


Top ↑

Changelog

Changelog
VersionDescription
5.2.2Introduced.

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.