Skip to:
Content
Pages
Categories
Search
Top
Bottom

Add Column to Admin bp-groups page


  • jamesmct
    Participant

    @jamesmct

    I saw some dev work on being able to create plugins that add columns to the admin groups page, but I can’t seem to find anyone that displays the group has pending members. My site wanted to split up physical classes into individual groups to present information to the students. As new members are rolling in and signing up, its becoming hard to manage all the requests for access.

    I’d like to be able to see how many pending members there are, visit the group and just accept them, as opposed to search through all my emails, and then manage them individually that way.

    I have some moderate coding ability, can someone point me in the right direction on which calls I should be using or where to go?

    Thanks in Advance

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

  • shanebp
    Moderator

    @shanebp

    The groups admin page code does not include hooks for adding a column – afaik.
    Wrong – see below.


    jamesmct
    Participant

    @jamesmct

    Thanks for the directional push. I looked at the example, and then tried to look at the bp-groups page, and I think I’m just completely lost.

    I see the classes get made, and I see the call links to other pages, I try to follow the ball and……….
    I’ve met my coding match.

    Ultimately I’d like to add a Pending count to the main table, and I’d like to show the pending members in the groups page.
    I’d even take it as an addon if someone made it, but any additional help would be awesome.

    Thanks


    shanebp
    Moderator

    @shanebp

    My mistake – the required hooks do exist.
    Here is an example of adding a column to the Groups Admin page.

    > I’d like to show the pending members in the groups page.

    You can see the pending requests by visiting the Group page > Manage > Requests.


    jamesmct
    Participant

    @jamesmct

    I will look at the hook, but I have 40 groups to manage. I’d like to be able to see these at a glance instead of having to open each group individually or following a lengthy email process to approve them


    jamesmct
    Participant

    @jamesmct

    So I just wanted to update this in case anyone else was looking for something along these lines.
    I found some code on The Buddypress Codex page that spelled out how to actually add the column. From there I added some custom coding to it to allow it to link to the membership page and accept the requests:

    <?php
    
    /* BuddyPress Custom Code */
    
    // add the column
    function groups_admin_add_custom_column( $columns ) {
         
        $columns["pending_group_members"] = "Join Requests";
         
        return $columns;
     
    }
    add_filter( "bp_groups_list_table_get_columns", "groups_admin_add_custom_column" );
     
     
    // add the column data for each row
    function groups_admin_custom_column_content( $retval = "", $column_name, $item ) {
         
        if ( "pending_group_members" !== $column_name ) {
            return $retval;
        }
         
         
        if ( "private" == $item["status"] ) {
             
            $user_ids = BP_Groups_Member::get_all_membership_request_user_ids( $item["id"] );
             
            return "<a href='". site_url(). "/groups/". $item["slug"] ."/admin/membership-requests/'>" . count( $user_ids) . "</a>";
        }
         
        return "-";
         
    }
    add_filter( "bp_groups_admin_get_group_custom_column", "groups_admin_custom_column_content", 10, 3 );
    
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.
Skip to toolbar