Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: [Resolved] Profile > Field > Default Visibility / Getting a field’s visability

@shanebp

Moderator

I wouldn’t rely on messing with visibility settings.
To make a profile field only editable by admins, do this in bp-custom.php or a plugin:

// only admins can edit the Skills field
function chief_hide_profile_fields( $retval ) {
	
	if( is_super_admin () )
		return $retval;

	if(  bp_is_profile_edit() || bp_is_register_page() )
		$retval['exclude_fields'] = '3';	//profile field ID's separated by comma

	return $retval;

}
add_filter( 'bp_after_has_profile_parse_args', 'chief_hide_profile_fields' );

Note that you need to add the correct id(s) for exclude_fields.
And that ‘ || bp_is_register_page() ‘ keeps the field(s) off the register page – which you may not need to do.

Re how to create profile fields in code, there a couple of ways to do it depending on the kind of field and how it will be used.
Take a look at these plugins for more info:
https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/
https://wordpress.org/plugins/buddypress-xprofile-image-field/

Skip to toolbar