Skip to:
Content

BuddyPress.org

Opened 12 years ago

Closed 11 years ago

#2377 closed enhancement (fixed)

Create show_hidden argument for bp_has_groups

Reported by: boonebgorges's profile boonebgorges Owned by:
Milestone: 1.5 Priority: major
Severity: Version:
Component: Core Keywords: has-patch
Cc:

Description

I'm working on a plugin http://teleogistic.net/code/buddypress/bp-system-report/ that uses WP's pseudo-cron to take regular snapshots of the BP installation, but I found that the script wasn't counting hidden groups. On closer examination, it's because hidden groups are being excluded from the query on

if ( !is_user_logged_in()
( !is_site_admin() && ( $user_id != $bp->loggedin_user->id ) ) )

That conditional returns false for the automated script, and there's no way to get around it with filters because it happens immediately before the query (which seems wrong to me anyway, as all other contextual arguments are determined outside of bp-groups-classes.php).

The attached patch adds an argument $show_hidden to bp_has_groups.

I'm tagging it 1.2.4 because I'm a bit desperate for a fix :) but I understand that it's late in the game so it's OK to bump to 1.3 if necessary.

Attachments (3)

show_hidden_groups_toggle.patch (4.7 KB) - added by boonebgorges 12 years ago.
2377.diff (6.3 KB) - added by sorich87 11 years ago.
2377-2.patch (6.8 KB) - added by DJPaul 11 years ago.

Download all attachments as: .zip

Change History (10)

#1 @boonebgorges
12 years ago

  • Milestone changed from 1.2.4 to 1.3

Crap, I just realized that I wrote the patch against trunk, where the group database class has been slimmed down a lot (nice job on that, by the way). So it's not going to work for 1.2.4.

#2 @paulhastings0
12 years ago

  • Summary changed from Create show_hidden argument for bp_has_groups (has patch!) to [patch] Create show_hidden argument for bp_has_groups

#3 @DJPaul
11 years ago

  • Keywords needs-refresh added; has-patch needs-testing removed
  • Summary changed from [patch] Create show_hidden argument for bp_has_groups to Create show_hidden argument for bp_has_groups

@sorich87
11 years ago

#4 @sorich87
11 years ago

  • Keywords has-patch added; needs-refresh removed

@DJPaul
11 years ago

#5 @DJPaul
11 years ago

2377-2 resolves a PHP notice; patch looks good but uncertain about this logic in bp_groups_template(). Boone, can you cast your eye over it please?

if ( is_site_admin() || ( is_user_logged_in() && $user_id == $bp->loggedin_user->id ) )
			$show_hidden = true;

#6 @boonebgorges
11 years ago

Logic is good. It's just the converse of what was already there. Basically, show_hidden should default to true when (1) you are the super admin, or (2) you're looking at your own My Groups (in other words, your id == the user_id param of bp_has_groups()).

Make sure to swap the is_site_admin() with is_super_admin().

#7 @djpaul
11 years ago

  • Resolution set to fixed
  • Status changed from new to closed

(In [3648]) Add show_hidden argument for bp_has_groups(). Fixes #2377. Props boonebgorges and sorich87

Note: See TracTickets for help on using tickets.