Information at forms don't stay saved at the profile information of user

Hi guys!

The information “CPF” and “Telefone” requested at the forms, don’t stay saved in profile of user.

An user just can register on site, if informed the “CPF” and “Telefone” are mandatory fields

Exist the possibility of the information “CPF” and “Telefone” stay saved on user profile page?

Thanks!

Please let me know how you added these fields to the user registration form, using a custom code snippet? By default there’s no option to move fields to the initial registration form.

I used this:

add_action(
	'hivepress/v1/models/user/register',
	function( $user_id, $values ) {
		if(isset($values['first_name'], $values['last_name'])){
			update_user_meta($user_id, 'first_name', $values['first_name']);
			update_user_meta($user_id, 'last_name', $values['last_name']);
			update_user_meta($user_id, 'telefone', $values['telefone']);
			update_user_meta($user_id, 'cpf', $values['cpf']);
		}
	},
	10, 
	2
);

add_filter(
	'hivepress/v1/forms/user_register',
	function ( $args, $form ) {
		$args['fields'] = array_merge($args['fields'], [
			'first_name' => [
				'label' => 'Nome',
				'type'    => 'text',
				'required' => true,
				'_order' => 1,
			],
			
			'last_name' => [
				'label' => 'Sobrenome',
				'type'    => 'text',
				'required' => true,
				'_order' => 2,
			],
			
			'cpf' => [
				'label' => 'CPF',
				'type'    => 'text',
				'required' => true,
				'_order' => 3,
			],
			
			'telefone' => [
				'label' => 'Telefone',
				'type'    => 'phone',
				'required' => true,
				'_order' => 4,
			],
			
		]);

		return $args;
	},
	10,
	2
);

If there are custom vendor attributes please try adding the hp_ prefix when saving them using update_post_meta, for example:

update_user_meta($user_id, 'hp_telefone', $values['telefone']);

Yes this worked, thank you.

We get make this with users without listings?

I needed that all users with and without listings had this information saved in profile page.

Sorry, there’s no such functionality for regular users yet since they don’t have public profile pages in the current version, but we plan to add the same custom attributes functionality as for vendors.

1 Like