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’权限。

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
查看更多 >