Skip to:
Content
Pages
Categories
Search
Top
Bottom

Filter User posts within specific Group


  • sx1001
    Participant

    @sx1001

    Hello dear forum community,

    do you have an idea how to solve this: in the list of displayed activity comments within a certain group, which I can identify by the group ID, I want to show only the contributions of the currently logged in user.

    So in the end a kind of filter that acts as if the database entries of other users wouldnt be there at all (maybe by manipulating the returned result set). I want to set up a support forum where each user sees only his own support requests.

    Is there a “bp user can” hook which could help?
    Thanks!

Viewing 1 replies (of 1 total)

  • sx1001
    Participant

    @sx1001

    Got it, looks good…
    This codes applies to group 5, i.e. within group 5, a user can only see his own posts AND the posts of admins:

    add_filter('bp_before_activity_get_parse_args', function($r) 
    {
        if(current_user_can('administrator'))
            return $r;
        
        if(@$r['filter']['object'] == 'groups' && @@$r['filter']['primary_id'] == 5) {
            $r['filter']['user_id'] = array_merge(get_users(array('role' => 'administrator', 'fields' => 'ID')), array(bp_loggedin_user_id()));
        }
    
        return $r;
    }, 1, 1);
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.
Skip to toolbar