wp_maybe_grant_site_health_caps

函式
wp_maybe_grant_site_health_caps ( $allcaps, $caps, $args, $user )
引數
  • (bool[]) $allcaps An array of all the user's capabilities.
    Required:
  • (string[]) $caps Required primitive capabilities for the requested capability.
    Required:
  • (array) $args { Arguments that accompany the requested capability check. @type string $0 Requested capability. @type int $1 Concerned user ID. @type mixed ...$2 Optional second and further parameters, typically object ID. }
    Required:
  • (WP_User) $user The user object.
    Required:
返回值
  • (bool[]) Filtered array of the user's capabilities.
定義位置
相關方法
wp_maybe_grant_resume_extensions_capswp_maybe_grant_install_languages_capwp_dashboard_site_healthwp_maybe_update_user_countswp_validate_site_data
引入
5.2.2
棄用
-

wp_maybe_grant_site_health_caps: 這個函式授予使用者訪問網站健康功能的許可權。它檢查使用者是否有管理選項的許可權,如果沒有,它將該許可權授予使用者的角色。

過濾使用者許可權,以便在必要時授予’view_site_health_checks’許可權。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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;
}
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; }
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;
}

常見問題

FAQs
檢視更多 >