Reply To: Profile Details

Home Forums User Registration Profile Details Reply To: Profile Details

#5583

sanjeev3
Member

Hello Paulo,

You need to filter the fields too. You may use this filter. Looks like field_key is redundant here. Assuming user_email is a required field for the form.

add_filter( 'user_registration_profile_account_filter_user_email', 'filter_data' );

function filter_data( $filter_data ) {
	$filter_data['fields']['user_registration_first_name'] = array
                (
 			    "label"        => 'First Name',
			    "description"  =>  '',
			    "type"         => 'text',
			    "field_key"    => 'last_name',
			    "required"     =>'',
			    "default"      => '',
    );

    $filter_data['fields']['user_registration_last_name'] = array
                (
 			    "label"        => 'Last Name',
			    "description"  =>  '',
			    "type"         => 'text',
			    "field_key"    => 'last_name',
			    "required"     =>'',
			    "default"      => '',
    );

    return $filter_data;
}

Also, instead of directly editing the template, you can also use this filter. However, it is okay, if you have overridden the template in the child theme.

add_filter( 'user_registration_profile_to_edit', 'ur_profile' );
function ur_profile( $profile ) {

	$current_user = wp_get_current_user();

	$teste = array('user_registration_first_name' =>
					array(
						"label"        => 'First Name',
						"description"  =>  '',
						"type"         => 'text',
						"field_key"    => 'first_name',
						"required"     =>'',
						"default"      => '',
						"value"        => $current_user->first_name,
					),
			 'user_registration_last_name' =>
					array(
						"label"        => 'Last Name',
						"description"  =>  '',
						"type"         => 'text',
						"field_key"    => 'last_name',
						"required"     =>'',
						"default"      => '',
						"value"        => $current_user->last_name,
					)

	);

	$profile = array_merge( $teste, $profile );
	return $profile;
}

Let us know if you have any further confusion.

Regards,
WPEverest Support