Opened 14 years ago
Closed 14 years ago
#2377 closed enhancement (fixed)
Create show_hidden argument for bp_has_groups
Reported by: | 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)
Change History (10)
#2
@
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
@
14 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
#5
@
14 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
@
14 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().
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.