Form values are stored in database even if the validation is NOT successful

If I fill and return errors[], form values are stored in database anyway!

	function( $errors, $form ) {		
		$errors[] = 'dummy error';
		return $errors;

Please try changing the priority of this callback, e.g. set it to anything less than 100. This issue occurs because the same hook is used for saving the vendor fields, and they are saved earlier than your custom function is called hivepress/class-vendor.php at master · hivepress/hivepress · GitHub

I tried changing the priority to 10, then 9… then 1 … and the issue still occurs. Just in case, the form name to reproduce the issue is “user_update_profile” instead of “user_update”

I too noticed that something is off. I have two categories for vendors, and when on the register vendor form, and switching between these categories, on page refresh the next step to make a listing is initiated. Even though i diddnt touch the submit button on the register vendor form.

Since the user_update form is a parent of the user_update_profile form, the validation errors hook is fired earlier for it so the vendor fields are saved before the hivepress/v1/forms/user_update_profile/errors hook. We’ll try to find another way to save the vendor fields (the current solution is a bit hacky), meanwhile please try this hook hivepress/v1/forms/user_update/errors with priority lower than 100. You can check if the current form is user_update_profile by checking some field value that doesn’t exist in the user_update one.

This issue probably occurs because there are no other required fields in the form, the Category is the only required one so once you select it and manually refresh the page the form is valid and skipped to the next Add Details step.

Hi ihor!
I tried the hivepress/v1/forms/user_update/errors hook and the validation worked fine without storing values in database when error occurs.

1 Like