How can I make the first name, last name, profile image required

I would like to know how can I change the next field like required and additionally add a field for phone number and that is also required

Hi!
Please try these code snippets (tutorial - How to add custom code snippets - HivePress Help Center):

  1. For Profile Image:
add_filter(
	'hivepress/v1/forms/user_update/errors',
	function( $errors, $form ) {
		$user = $form->get_model();

		if ( $user && ! $user->get_image__id() ) {
			$errors[] = 'Please upload the profile image.';
		}

		return $errors;
	},
	100,
	2
);

add_filter(
	'hivepress/v1/forms/user_update',
	function( $form ) {
		$form['fields']['image']['statuses']['optional'] = null;

		return $form;
	},
	1000
);
  1. For First and Last Name:
add_filter(
	'hivepress/v1/forms/user_update',
	function( $form ) {
		$form['fields']['first_name']['required'] = true;
		$form['fields']['last_name']['required'] = true;

		return $form;
	},
	1000
);
2 Likes

Thenks this helped me but it is still pending to add the telephone number field in the registration of new users and that this field be verified by sending an SMS

Hi,
Unfortunately, there’s no simple code snippet for adding this feature, but thanks for your feedback - we added this feature to the HivePress roadmap.

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