BuddyDev

Search

Replies

  • Participant
    Level: Initiated
    Posts: 2
    Jemima on #31503

    Hi Brajesh,

    Thanks very much for your reply. I’m glad it’s not obvious, at least!

    I have found another way, as follows. Does this look good to you? From what I can tell, it’s ok, but there might be something obviously wrong with it that your experience will quickly spot?

    add_action( 'bp_pre_user_query_construct', 'wd_build_exclude_args', 20, 1 );
    
     function wd_build_exclude_args($args) {
        
        $excluded = isset( $args->exclude ) ? $args->exclude : array();
    
        $user_ids = get_users( array( 'role__in' => ['subscriber'], 'fields' => 'ID' ) );
        $excluded = array_merge( $excluded, $user_ids );
     
        $args->query_vars['exclude'] = $excluded;
    
        return $args;
      }

    Thank you!

    Jemima

  • Participant
    Level: Initiated
    Posts: 2
    Jemima on #31352

    Hi Brajesh,

    Many thanks. Sorry for not including that initially. I’m using BuddyPress version 6.1.0.

    Thanks

    Jemima