BP_Core_Members_Switching::filter_map_meta_cap( string[] $required_caps, string $cap, int $user_id, array $args )
Filters the required primitive capabilities for the given primitive or meta capability.
Description
This is used to:
- Add the ‘do_not_allow’ capability to the list of required capabilities when a Super Admin is trying to switch to themselves.
It affects nothing else as Super Admins can do everything by default.
Parameters
- $required_caps
-
(Required) Required primitive capabilities for the requested capability.
- $cap
-
(Required) Capability or meta capability being checked.
- $user_id
-
(Required) Concerned user ID.
- $args
-
(Required) Arguments that accompany the requested capability check
Return
(string[]) Required capabilities for the requested action.
Source
File: bp-members/classes/class-bp-core-members-switching.php
public function filter_map_meta_cap( array $required_caps, $cap, $user_id, array $args ) { if ( isset( $args[0] ) && ( 'switch_to_user' === $cap ) && ( $args[0] === $user_id ) ) { $required_caps[] = 'do_not_allow'; } return $required_caps; }
Changelog
Version | Description |
---|---|
BuddyBoss 1.0.0 | Introduced. |
Questions?
We're always happy to help with code or other questions you might have! Search our developer docs, contact support, or connect with our sales team.