Why is the phone number not saved in the new user's settings?

Hi, please help me solve the problem. By Request the phone number in the subscrition form We decided to create a phone number login for all types of users, but the phone number is not saved if you enter it during registration. Here is a screenshot of the seller and user attribute settings using another plugin.

Both attributes look like this

And snippet

add_filter(
    'hivepress/v1/forms/user_register',
    function ( $form ) {
        $form['fields'] = array_merge(
            $form['fields'],
            [
                'hp_telephone' => [
					'label' => 'Phone number',
                    'type' => 'phone',
                    'required' => true,
                    'country' => 'RU',
                    '_order' => 1,
                ],
            ]
        );
        
        return $form;
    },
    1000
);

add_action('hivepress/v1/models/user/create', 
		   function ($user, $values) {
			   if (isset($values['hp_telephone'])) {
				   update_user_meta($user->get_id(), 'hp_hp_telephone', $values['hp_telephone']);
    }
}, 1000, 2);


and we used this code

If you have the latest HivePress version, then the code snippet is not needed, user attributes marked both Editable and Required will appear in the registration form automatically.

Thanks for the answer!

Correction: The field actually appeared on the registration form after the update. And how do I add a field to the login form? Through a snippet?

Hi,

Well, it is possible, but it will require PHP snippets, please check this sample: Add first and last name fields to the user registration form #hivepress #users · GitHub

Ok, thanks guys.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.