As requested by Janis, here is the code I use to show only certain xprofile groups to each user type. In the default BuddyPress theme, profile fields without a value aren’t shown, so only the ones for that group will appear to the public.
You will need to replace a function call in your BuddyPress theme, in /members/single/profile/edit.php. It is at line 12 in mine.
Find
<?php bp_profile_group_tabs(); ?>
And replace it with this:
<?php my_bp_profile_group_tabs(); ?>
In /plugins/bp-custom.php place the following code. You will need to edit it to fit your user type and profile group needs.
function my_bp_profile_group_tabs() {
global $bp, $group_name;
$signup_type = get_user_meta($bp->loggedin_user->id, 'signup_type', true);
if ( !$groups = wp_cache_get( 'xprofile_groups_inc_empty', 'bp' ) ) {
$groups = BP_XProfile_Group::get( array( 'fetch_fields' => true ) );
wp_cache_set( 'xprofile_groups_inc_empty', $groups, 'bp' );
}
if ( empty( $group_name ) )
$group_name = bp_profile_group_name(false);
for ( $i = 0; $i < count($groups); $i++ ) {
if ( $signup_type == 'usertypea' && ( $groups[$i]->name == 'Base Profile' || $groups[$i]->name == 'Profile Group A' || $groups[$i]->name == 'Profile Group B' ) ) {
if ( $group_name == $groups[$i]->name ) {
$selected = ' class="current"';
} else {
$selected = '';
}
if ( $groups[$i]->fields )
echo '<li' . $selected . '><a href="' . $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . attribute_escape( $groups[$i]->name ) . '</a></li>';
} elseif ( $signup_type == 'usertypeb' && ( $groups[$i]->name == 'Base Profile' || $groups[$i]->name == 'Profile Group C' ) ) {
if ( $group_name == $groups[$i]->name ) {
$selected = ' class="current"';
} else {
$selected = '';
}
if ( $groups[$i]->fields )
echo '<li' . $selected . '><a href="' . $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . attribute_escape( $groups[$i]->name ) . '</a></li>';
} elseif ( $signup_type == 'usertypec' && ( $groups[$i]->name == 'Base Profile' || $groups[$i]->name == 'Profile Group D' ) ) {
if ( $group_name == $groups[$i]->name ) {
$selected = ' class="current"';
} else {
$selected = '';
}
if ( $groups[$i]->fields )
echo '<li' . $selected . '><a href="' . $bp->displayed_user->domain . $bp->profile->slug . '/edit/group/' . $groups[$i]->id . '">' . attribute_escape( $groups[$i]->name ) . '</a></li>';
}
}
do_action( 'xprofile_profile_group_tabs' );
}