How Can We Help?

Control if user can make audio/video call with hooks

You are here:
< All Topics
add_filter('bp_better_messages_can_audio_call', 'disable_calls', 10, 3);
add_filter('bp_better_messages_can_video_call', 'disable_calls', 10, 3);

function disable_calls( $can_call, $user_id, $thread_id ){

    if( ! $can_call ) return $can_call;
    
    $user = get_userdata($user_id);
    $allowed_roles = (array)['administrator', 'other_role'];
    $user_roles = (array) $user->roles;
    $is_allowed = false;

    foreach ($user_roles as $user_role) {
        if (in_array($user_role, $allowed_roles)) {
            $is_allowed = true;
        }
    }
    
    return $is_allowed;
}
Table of Contents