WPCOM_VIP_Support_Role::filter_user_has_cap PHP Method

filter_user_has_cap() public method

Rather than explicitly adding all the capabilities to the admin role, and possibly missing some custom ones, or copying a role, and possibly being tripped up when that role doesn't exist, we filter all user capability checks and wave past our VIP Support users as automattically having the capability being checked.
public filter_user_has_cap ( array $user_caps, array $caps, array $args, WP_User $user ) : array
$user_caps array An array of all the user's capabilities.
$caps array Actual capabilities for meta capability.
$args array Optional parameters passed to has_cap(), typically object ID.
$user WP_User The user object.
return array An array of all the user's caps, with the required cap added
    public function filter_user_has_cap(array $user_caps, array $caps, array $args, WP_User $user)
    {
        if (in_array(self::VIP_SUPPORT_ROLE, $user->roles)) {
            foreach ($caps as $cap) {
                $user_caps[$cap] = true;
            }
        }
        return $user_caps;
    }