Skip to:
Content
Pages
Categories
Search
Top
Bottom

Added a filter in the member directory.


  • kamelblua
    Participant

    @kamelblua

    Hello, I added a drop down with as option the groups created by the users, my goal is when you click on a specific group, it displays the members of the group, cordially.

    Do you know how I can do that please?

    Screen :

    filter group

    filter group

    code :

    function add_dropdown_filter_society() {
    
        ?>
        <div class="flex bp-secondary-header align-items-center">
            <div class="push-right flex">
                <select id="groups-order-by" data-bp-filter="members">
                    <option value="active">Société</option>
                    <?php
                    $groups = groups_get_groups();
                    foreach( $groups["groups"] as $group ) {
    
                        ?> <option value="society"> <?php echo $group->name; ?> </option> <?php
    
                    }
                    ?>
                </select>
            </div>
        </div>
        <?php
    
    }
    add_action('bp_before_directory_members_content', 'add_dropdown_filter_society',10,3);
Viewing 3 replies - 1 through 3 (of 3 total)

  • shanebp
    Moderator

    @shanebp

    To get group members, use groups_get_group_members


    kamelblua
    Participant

    @kamelblua

    Thanks for the answer, I will look into this method.


    kamelblua
    Participant

    @kamelblua

    Hello, I come back to you, because I did not succeed what I wanted to do, moreover I made some modification in my code, in fact I do not want to filter by groups, but by a meta then, already I coded the code to obtain a user by a meta_value and a meta_key, but I do not know how to add my request in the loop members for which displays me the user in the content members.

    function add_filter_society() {
        ?>
        <div class="bp-members-filter-wrap subnav-filters filters no-ajax">
    
            <div id="dir-filters-rubrash" class="component-filters clearfix">
    
                <div id="members-order-select-rubrash" class="last filter">
                    <label class="bp-screen-reader-text" for="members-order-by">
                        <span>Trier par:</span>
                    </label>
                    <div class="select-wrap">
                        <select id="members-order-by-rubrash" data-bp-filter="members">
    
                            <option selected>Filtre par société</option>
    
                            <?php
                            global $wpdb;
    
                            $society_meta = $wpdb->get_results( "SELECT distinct meta_value FROM $wpdb->usermeta WHERE meta_key = 'mepr_societe_facultatif'");
    
                            foreach($society_meta as $society) {
    
                                if(!empty($society->meta_value)) {
                                    ?> <option> <?php echo $society->meta_value; ?> </option> <?php
                                }
                                ?>
                            <?php } ?>
    
                        </select>
                        <span class="select-arrow" aria-hidden="true"></span>
                    </div>
                </div>
            </div>
        </div>
    
        <?php
    
    }
    add_action('rb_enter_directory_members_content', 'add_filter_society');
    
    function get_member_by_society() {
    
        $user_query_meta = get_users(array(
            'meta_key' => 'mepr_societe_facultatif',
            'meta_value' => 'selectOption'
        ));
    
    }
    add_action('rb_enter_directory_members_content', 'get_member_by_society');

    Do you have an idea?

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar