Skip to:
Content
Pages
Categories
Search
Top
Bottom

opt out of directory


  • MC-land
    Participant

    @michaeliresource

    Hi,

    I have found previous help on how to exclude by ID but thats not what i want to do with manually inputting potentially hundreds of different user ID.
    Is there a way to allow the user to opt out of the directory?

    I have added in a checkbox input to the members->single->settings->general.php file after the password fields, which says “opt out of members directory”.
    How do i take that input and customise the directory loop?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)

  • shanebp
    Moderator

    @shanebp

    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


    MC-land
    Participant

    @michaeliresource

    Thanks Shane!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘opt out of directory’ is closed to new replies.
Skip to toolbar