Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How To Show Groups That Only You (Or a User) Has Created (Not Joined) (6 posts)

Started 1 year, 8 months ago by: Dimensionmedia

  • Profile picture of Dimensionmedia Dimensionmedia said 1 year, 8 months ago:

    I’m trying to modify things slightly so that the main groups tab only shows groups that the user has CREATED (not joined, as I believe is the default).

    I’ve looked at bp_has_groups (both the function in the code and the docs) and there aren’t any filters for this. I don’t have a problem duplicating functions just to add this, but this request doesn’t look straightforward to me. In fact, quite messy. I want to use BuddyPress’s functions and not create my own because of the built in pagination, etc. Any suggestions or recommendations?

  • Profile picture of Ron Rennick Ron Rennick said 1 year, 8 months ago:

    You could strip it down to just groups that the person is an admin of with

    if( !bp_group_is_admin() ) { continue; }

    However, that wouldn’t adjust your counts/pagination.

  • Profile picture of Dimensionmedia Dimensionmedia said 1 year, 8 months ago:

    Yeah, I thought of that – although I didn’t think of bp_group_is_admin so your way is better than mine – but the count/pagination is the killer. Actually, just the pagination is since I could come up with the count easily.

    Still playing around, though. Thanks Ron for helping me refine what I had.

  • Profile picture of Dimensionmedia Dimensionmedia said 1 year, 8 months ago:

    Followup: I have created a trac for this. Thanks to @boonebgorges and @pgibbs for the suggestion.

  • Profile picture of rich! @ etiviti rich! @ etiviti said 1 year, 8 months ago:

    interim – what about filtering on bp_has_groups and unset the items? (and readjust the count)

  • Profile picture of John James Jacoby John James Jacoby said 1 year, 8 months ago:
    function new_group_is_admin_loop( $user_id = 0 ) {
        global $bp, $groups_template;
    
        if ( empty( $user_id ) )
            $user_id = $bp->loggedin_user->id;
    
        $groups_template = BP_Groups_Member::get_is_admin_of( $user_id );
    }

    …or something similar? Untested so your mileage may vary.

    Chances are this won’t work, thinking back on it now. But, give it a shot. At the very least that function will return back the groups that the user is the admin of; you may need to do your own custom loop functions afterwards.