BP_Group_Extension::group_access_protection( bool $user_can_visit, array $no_access_args )

Filter the access check in bp_groups_group_access_protection() for this extension.

Description

Note that $no_access_args is passed by reference, as there are some circumstances where the bp_core_no_access() arguments need to be modified before the redirect takes place.

Parameters

$user_can_visit

(Required) Whether or not the user can visit the tab.

$no_access_args

(Required) Array of args to help determine access.

Return

(bool)

Source

File: bp-groups/classes/class-bp-group-extension.php

880
881
882
883
884
885
886
887
888
889
890
891
892
public function group_access_protection( $user_can_visit, &$no_access_args ) {
    $user_can_visit = $this->user_can_visit();
 
    if ( ! $user_can_visit && is_user_logged_in() ) {
        $current_group = groups_get_group( $this->group_id );
 
        $no_access_args['message'] = __( 'You do not have access to this content.', 'buddyboss' );
        $no_access_args['root'] = bp_get_group_permalink( $current_group ) . 'home/';
        $no_access_args['redirect'] = false;
    }
 
    return $user_can_visit;
}

Changelog

Changelog
Version Description
BuddyPress 2.1.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.