How to make Vendor registration fields required

Hi ihor, you said— "If you add at least 1 required vendor attribute or make any of the existing fields required (e.g. first/last name, using a code snippet) then there will be 2 steps: login/registration and “complete profile”

  1. Do you have an example of the code snippet to use?
  2. Where would I add the code snippet in Word Press?
  3. Do I need a new plugin to add the code snippet to?
  4. How do I add additional fields/data points to the registration form?
    4a. Where would those data points be stored within WordPress?

Thank you!

I found this, but it didn’t work for my page. Any thoughts as to why?


// Make First name and Last name fields required.
add_filter(
	'hivepress/v1/forms/user_update',
	function( $form ) {
		if(current_user_can('edit_posts')){
			$form['fields']['first_name']['required'] = true;
			$form['fields']['last_name']['required'] = true;	
		}

		return $form;
	},
	1000
);
// Make Image field required.
add_filter(
	'hivepress/v1/forms/user_update/errors',
	function( $errors, $form ) {
		$user = $form->get_model();

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

		return $errors;
	},
	100,
	2
);

Hi,

  1. Yes, these are the correct snippets.

2, 3. Please try following these instructions How to add custom code snippets - HivePress Help Center

  1. You can add custom vendor fields (attributes) in Vendors/Attributes section, e.g. mark them as Editable and Required. The storage depends on the attribute type, e.g. text attributes are stored in wp_postmeta, while selectable attributes are stored in wp_terms database table.

Please test this as a new user, if there’s at least 1 required field, then an extra Complete Profile step will appear in the listing process.

This solved my problem! Thank you ihor!

please am facing the same issues how can i make the vendor first and last name required thanks (Vendor registration form)

the code above for it doesn’t work for me

Please try this code snippet and make sure that it’s added correctly (via the Code Snippets plugin) Make first and last name fields required for users #hivepress #users · GitHub

Thanks