Hi Ekiz,
Please put this code in your bp-custom.php/** * Don't allow changing full name on BuddyPress Edit profile. * * Pre-process $_POST and overwrite the full name field data to avoid update by users. */ function buddydev_overwrite_name_update() { if ( empty( $_POST['field_ids'] ) || is_super_admin() ) { //allow super admins. return; } $field_id = bp_xprofile_fullname_field_id(); $field = 'field_' . $field_id; if ( empty( $_POST[ $field ] ) ) { return; //not set. } // Check the field group exists. if ( ! bp_is_action_variable( 'group' ) || ! xprofile_get_field_group( bp_action_variable( 1 ) ) ) { return; } // overwrite with raw value. // avoiding displayed_user_name and get_field_data as they provide extra filtering. $_POST[ $field ] = maybe_unserialize( BP_XProfile_ProfileData::get_value_byid( $field_id, bp_displayed_user_id() ) ); } add_action( 'bp_screens', 'buddydev_overwrite_name_update', 2 );
That will do it for you.
You can hide the field using css. User edit’s won’t have any effect.
Regards
Brajesh
Viewing 6 posts - 1 through 6 (of 6 total)
The topic ‘ [Resolved] Buddypress – How to Hide / Restrict Primary Name field?’ is closed to new replies.
This topic is: resolved