Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: opt out of directory

@shanebp

Moderator

There are a couple of ways to do that.
Try:

function iresource_exclude_ids( $retval ) {
    global $wpdb;

    $field_id = xprofile_get_field_id_from_name( 'FIELD NAME GOES HERE' ); 

    $query = "SELECT user_id FROM " . $wpdb->prefix . "bp_xprofile_data WHERE field_id = " . $field_id . "AND value = 'FIELD VALUE GOES HERE'";

    $exclude_ids = $wpdb->get_col( $query );

    $retval['exclude'] = implode(",", $exclude_ids);
 
    return $retval;
}
add_filter( 'bp_after_has_members_parse_args', 'iresource_exclude_ids' );

More info:

Using bp_parse_args() to filter BuddyPress template loops

Skip to toolbar