8 pointsGetting my WPMU DEV WingsI'm new here
Creative Slice
Member
—
1st February 2012 (3 months ago)
I'm trying to show content to members of a certain group in BuddyPress. Is there a function (or some way) to find out which groups the current user is a member of?
I'm trying to show content to members of a certain group in BuddyPress. Is there a function (or some way) to find out which groups the current user is a member of?
/**
* bp_group_is_member()
*
* Checks if current user is member of a group.
*
* @uses is_super_admin Check if current user is super admin
* @uses apply_filters Creates bp_group_is_member filter and passes $is_member
* @usedby groups/activity.php, groups/single/forum/edit.php, groups/single/forum/topic.php to determine template part visibility
* @global array $bp BuddyPress Master global
* @global object $groups_template Current Group (usually in template loop)
* @param object $group Group to check is_member
* @return bool If user is member of group or not
*/
Thanks for the suggestion. I actually had been trying out the bp_group_is_member() however I could not figure out how to get a specific group into this function. For example:
5571 pointsLike some sort of WPMU DEV GodMindblowingly helpful memberLifetime member
Support Kangaroo
—
10th February 2012 (3 months ago)
#
Greetings Creative Slice,
It can be pretty challenging to support other peoples work, but we do our best here to help you with any WordPress issues at all, so let's see what we can do!
What I will do is see if I can get a lead developer in here to assist / give you some advice.
Responses (9)
Support Chimp — 2nd February 2012 (3 months ago) #
Hey Tim, how are you?
Perhaps this function will help:
bp_group_is_member()You can also find a list of functions here:
http://codex.buddypress.org/developer-docs/functions/
Hope this helps.
Take care.
Member — 2nd February 2012 (3 months ago) #
Thanks for the suggestion. I actually had been trying out the bp_group_is_member() however I could not figure out how to get a specific group into this function. For example:
If current user is member of Group1 then...
Any idea how to have it work like this?
Thanks!
Support Chimp — 7th February 2012 (3 months ago) #
Hey there again...
You should find the following page of some use:
http://codex.buddypress.org/developer-docs/buddypress-template-tags/
There are a number of functions in there which might be os use. :-)
Take care.
Member — 7th February 2012 (3 months ago) #
Thanks, we've been looking at the template tag page however it doesn't appear to have a function to show what group a user is part of.
Any idea how this might be done?
Thanks again.
Member — 10th February 2012 (3 months ago) #
Any help on this topic?
Support Kangaroo — 10th February 2012 (3 months ago) #
Greetings Creative Slice,
It can be pretty challenging to support other peoples work, but we do our best here to help you with any WordPress issues at all, so let's see what we can do!
What I will do is see if I can get a lead developer in here to assist / give you some advice.
Thank you for being a WPMU Dev member!
Cheers, Joe :-)
Lead Developer — 10th February 2012 (3 months ago) #
You can pass bp_group_is_member($group) a group object. I think you can do this:
Member — 10th February 2012 (3 months ago) #
Thanks for your help Aaron. I've got it nearly working with your direction and am hoping you can help with the last few details.
The
if (bp_group_is_member($group))part doesn't seem to be working so I did aprint_r($groups);and found this:BP_Groups_Group Object ( [id] => group-three [creator_id] => [name] => [slug] => [description] => [status] => [enable_forum] => [date_created] => [admins] => [mods] => [total_member_count] => )Is there a way I can use this to see if the logged in user is a member of "group-three"?
Thanks so much for your help.
- Tim
Lead Developer — 10th February 2012 (3 months ago) #
You need to get the ID number for your group. Maybe from the db.
Become a member