`groups_is_user_member( $user_id, $group_id )`
It doesn’t work, and I have later to display the groups that member is user, so `$group`_id doesn’t know which group it matters.
have you tried the passing user id to the bp_get_total_group_count_for_user(), do not use bp_total_group_count_for_user(), it just echoes the count.
like
`
bp_get_total_group_count_for_user($user_id);
//or if inside member loop you may o this
global $members_template;
$total_group=bp_get_total_group_count_for_user($members_template->member->id);
`
For using @djpaul ‘s method you need to know group Id. That is best suited when you are on a group page or you know exactly which groups you want to check.
It doesn’t work better, and `bp_total_group_count_for_user( $user_id )` displays only “0”, as you can see here :
http://www.paul-emploi.biz/plan-du-site/
for the next hours. I’m trying to build a sitemap.
I’ve tried with `$members_template->member->user_id` and `$bp->displayed_user->id `, and many other ideas… It’s strange, because some native BP loops in that page become to work incorrectly.
have you used the get function bp_get_total_group_count_for_user(), as I said earlier, the bp_total_group_count_for_user does not return a value. so use bp_get_total_group_count_for_user
Yes I do, naturally ! I used the `bp_get_total_group_count_for_user()` function before, and seeing that it doesn’t work, I took the `bp_total_group_count_for_user()` function later, to see the reason why it doesn’t work. It’s very strange…
An other mystery in the group loop for instance, you can see that all the members are displayed, instead the members of a group only !
I have it, now !
`global $bp, $members_template;
if ( bp_get_total_group_count_for_user( $members_template->member->id ) > 0 )
return true; else return false;`
Thanks for both of you, @djpaul and @sbrajesh .
I know this thread is 2 years old. But here’s my problem:
I would like to display different member profiles for different types of groups. I have 2 groups: faculty and contributor. More accurately i want to disable components like bp Links and group docs wiki for the faculty group; i settled for removing the links to such.
i thought the best approach would be to check if a member is of a certain group and then based on the conditional statement, remove the unnecessary tabs in the profile menu. If there is a better approach. Please lead the way:)
in my theme’s function.php:
`
if(groups_is_user_member( bp_loggedin_user_id(), BP_Groups_Group::get_id_from_slug(‘faculty’))){
function setup_nav() {
global $bp;
// Remove a menu item
bp_core_remove_nav_item( ‘messages’ );
}
add_action( ‘bp_setup_nav’, ‘setup_nav’, 1000 );
}
`
if i make the conditional statement truthy the appropriate tab is removed. If i stick the code in the if statement into something like header.php it works. BUT for some reason, together they do not.
Perhaps functions.php cannot reach such functions? I tried putting it into bp-custom.php, site just crashed.
Thank you for your time, any help would be appreciated 🙂