Reply To: Displaying XProfile Field Groups Dependen on User Role
Hi,
Make sure to leave the base group profile fields available for all users
Then explore in this direction :
/* Profile display */
function excluding_group_id_depending_on_user_role( $args = array() ) {
if ( user_can( bp_dispayed_user_id(), 'capability_to_check' ) {
$args['exclude_groups'] = "2,3,4"; //Comma-separated list of profile field group IDs to exclude
}
return $args;
}
add_filter( 'has_profile', 'excluding_group_id_depending_on_user_role', 10, 1 );
/* profile editing */
It will be a bit more complex as you’ll need to filter ‘xprofile_filter_profile_group_tabs’ and use a pattern to exclude the tabs you don’t want the role to edit.
Finally to restrict group creation, i’ve shared a code on the BuddyPress fr community :
http://bp-fr.net/agora/sujet/restreindre-la-creation-des-groupes-a-des-roles-wp/