Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: [Resolved] Hide possibility to change ‘Base’ name

@danbp

Participant

Hi @amic58, @tecca

When BP is installed and xProfile is activated, the original WP profile settings are not accessible to user.

The WP register process use only username, password and email and BuddyPress add by default a Name field as base for other extended profile fields.

In short this means that username and name fields can contain a same information(a name, a pseudonym, a first or/and a last name). The plugin you mention is best for a WP install where user had choosen first/last name as output on post, comments, etc Once BP is activated, this became a little different.

Now to the initial question.
The CSS trick is a very inelegant solution as it lets everybody knowing how BP works to surround this invisibility. You’re also loosing any flexibility if you want to show some fields privately for example.

You can do this properly with a little snippet, as explained here:

Using bp_parse_args() to filter BuddyPress template loops

Here’s an example which let you hide fields or fiels group to members, but not to site admin

function bpfr_hide_profile_field_group( $retval ) {
	if ( bp_is_active( 'xprofile' ) ) :	
	
	// hide profile group/field to all except admin	
	if ( !is_super_admin() ) {		
		//exlude fields, separated by comma
		$retval['exclude_fields'] = '1';  
		//exlude groups, separated by comma
		$retval['exclude_groups'] = '1'; 			
	} 
	return $retval;		
	
	endif;
}
add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_field_group' );

Add it to bp-custom.php or your child-theme functions.php

Of course you can also choose to show a field or group, but remove the possibility for the user to edit it later. Simply add more conditionnal to the function.

Here another example:

function bpfr_hide_profile_edit( $retval ) {	
	// remove field from edit tab
	if(  bp_is_user_profile_edit() ) {		
		$retval['exclude_fields'] = '54'; // ID's separated by comma
	}	
	// allow field on register page
	if ( bp_is_register_page() ) {
		$retval['include_fields'] = '54'; // ID's separated by comma
		}		
	
	// hide the field on profile view tab
	if ( $data = bp_get_profile_field_data( 'field=54' ) ) : 
		$retval['exclude_fields'] = '54'; // ID's separated by comma	
	endif;	
	
	return $retval;	
}
add_filter( 'bp_after_has_profile_parse_args', 'bpfr_hide_profile_edit' );

Hope to be clear.

Skip to toolbar