Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/28/2023 04:15:02 PM (20 months ago)
Author:
dcavins
Message:

Introduce bp_view capability.

Introduce a new, base-level capability, bp_view,
that by default maps to the most base-level WordPress
capability, exist.

See #8734.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-core/bp-core-caps.php

    r13450 r13531  
    125125 *
    126126 * @since 1.6.0
     127 * @since 12.0.0 Added mapping for `bp_view` capability.
    127128 *
    128129 * @see WP_User::has_cap() for description of the arguments passed to the
     
    137138 */
    138139function bp_map_meta_caps( $caps, $cap, $user_id, $args ) {
     140
     141    switch ( $cap ) {
     142        case 'bp_view' :
     143            $caps = array( 'exist' );
     144            if ( ! $user_id ) {
     145
     146                // A BuddyPress component ID may be optionally passed with the `bp_view` check.
     147                $component = isset( $args['bp_component'] ) ? $args['bp_component'] : '';
     148
     149                if ( 'members' === bp_get_community_visibility( $component ) ) {
     150                    $caps = array( 'do_not_allow' );
     151                }
     152            }
     153            break;
     154    }
    139155
    140156    /**
Note: See TracChangeset for help on using the changeset viewer.