Skip to:

Opened 14 years ago

Closed 13 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


I'm working on a plugin 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 14 years ago.
2377.diff (6.3 KB) - added by sorich87 13 years ago.
2377-2.patch (6.8 KB) - added by DJPaul 13 years ago.

Download all attachments as: .zip

Change History (10)

#1 @boonebgorges
14 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
14 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
13 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

13 years ago

#4 @sorich87
13 years ago

  • Keywords has-patch added; needs-refresh removed

13 years ago

#5 @DJPaul
13 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
13 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
13 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.