Skip to:
Content
Pages
Categories
Search
Top
Bottom

Displaying group members roles in member list


  • Venutius
    Moderator

    @venutius

    I’ve tried searching for this but have not found a solution that works for me. How would I display the group members roles in the member list for a specific group. I’m thinking of the role within the group, not the WP role.

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

  • Henry Wright
    Moderator

    @henrywright

    I haven’t tried this but you could try doing something like this:

    function venutius_display_member_role() {
    
        global $members_template;
    
        // This is a confirmed group member.
        if ( $members_template->member->is_confirmed )
            echo '<p>Member</p>';
    
        // This is a group moderator.
        if ( $members_template->member->is_mod )
            echo '<p>Mod</p>';
    
        // This is a group admin.
        if ( $members_template->member->is_admin )
            echo '<p>Admin</p>';
    }
    add_action( 'bp_directory_groups_item', 'venutius_display_member_role' );

    Venutius
    Moderator

    @venutius

    I added it to the Members.php file but it seems to have no effect.


    Henry Wright
    Moderator

    @henrywright

    I added it to the Members.php file but it seems to have no effect.

    This should actually go in your theme’s functions.php file.


    Venutius
    Moderator

    @venutius

    Ah ok, my bad.

    I’ve moved it to functions but again it’s not doing anything


    Henry Wright
    Moderator

    @henrywright

    This will work, I’ve used the right hook this time, and tested myself to make sure it’s working:

    function venutius_display_member_role() {
    
        global $members_template;
    
        // This is a confirmed group member.
        if ( $members_template->member->is_confirmed )
            echo '<p>Member</p>';
    
        // This is a group moderator.
        if ( $members_template->member->is_mod )
            echo '<p>Mod</p>';
    
        // This is a group admin.
        if ( $members_template->member->is_admin )
            echo '<p>Admin</p>';
    }
    add_action( 'bp_group_members_list_item_action', 'venutius_display_member_role' );
    

    Venutius
    Moderator

    @venutius

    Yep that works! Thanks a lot!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Displaying group members roles in member list’ is closed to new replies.
Skip to toolbar