BpGroupReports::showTabOnView()

Determine who can see the tab

Description

Source

File: bp-integrations/learndash/buddypress/components/BpGroupReports.php

102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
protected function showTabOnView()
{
    if (! $currentGroup = groups_get_current_group()) {
        return 'noone';
    }
 
    $generator = bp_ld_sync('buddypress')->sync->generator($currentGroup->id);
    if (! $generator->hasLdGroup()) {
        return 'noone';
    }
 
    if (! learndash_group_enrolled_courses($generator->getLdGroupId())) {
        return 'noone';
    }
 
    // admin can always view
    if (learndash_is_admin_user()) {
        return true;
    }
 
    foreach (bp_ld_sync('settings')->get('reports.access', []) as $type) {
        $function = "groups_is_user_{$type}";
        if (function_exists($function) && call_user_func_array($function, [bp_loggedin_user_id(), $currentGroup->id])) {
            return true;
        }
    }
 
    return 'noone';
}

Changelog

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.