Users profile Attributes not to be optional

I need help how to edit users settings attributes not to be optional for name last name and profile image in hivepress listhive theme.

Thanks for your message — our team will reply shortly.

In the meantime, you can also get instant help from our AI Assistant, familiar with all the docs and solutions we’ve shared over the years.

Hi @evansringroad,

Use the following PHP code snippets to set the first name, last name and display picture as required fields.

<?php
add_filter(
	'hivepress/v1/forms/user_update',
	function( $form ) {
		$form['fields']['first_name']['required'] = true;
		$form['fields']['last_name']['required'] = true;

		return $form;
	},
	1000
);
<?php
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
);

You can read the following documentation regarding adding code snippets if you’re unfamiliar with doing so.

I hope this helps!

Cheers,
Chris :victory_hand:

1 Like

worked perfectly well. thank you! :victory_hand:

2 Likes

Happy I could help!

I hope you have a good weekend :blush:

Cheers,
Chris :victory_hand:

1 Like