When Vendor attribute is an attachment and required there is no error message

When a Vendor attribute is an attachment (image upload) and required there is no error message if an image is not loaded.

Steps to reproduce

Create a required attribute for vendors, select Attachment as the field type. Log Out.
Click the +Add Listing button, go to the SignIn form and click Register to register a new Vendor. Get as far as the “Complete Profile” form…

Actual result

If no image is loaded into the attachment field the form will not submit which is expected HOWEVER there is no error message showing which field needs to be filled out

Expected result

The “Please fill out this field” bubble should pop up indicating that an image needs to be entered into the field

Extra details

[Add a link to your site, screenshots or any other details that may help us pinpoint the issue.]
http://tagg-along.com

Thanks for reporting this, the bug is confirmed and we’ll fix it as soon as possible.

As a temporary fix please try this PHP snippet. Please just change your_attribute_field_name with your attribute field name.

add_filter(
	'hivepress/v1/forms/user_update_profile/errors',
	function ($errors, $form){
		if(!$form->get_value('your_attribute_field_name')){
			$errors[] = 'Please set attachment';
		}
		
		return $errors;
	},
	1000,
	2
);

Thank you!!

I will await the update.

Just so you know - the error message keeps coming back even after an attachment has been loaded.
The code snippet causes a few other issues as well - if you refresh the page all required attributes and the required profile pic are ignored and you are taken to the Add Details page.
Thanks for looking into this!!

Please try this PHP snippet instead as a temporary fix. Please just change get_your_attribute_field_name with get_ + your attribute field name.

add_filter(
	'hivepress/v1/forms/user_update_profile/errors',
	function ($errors, $form){
		$vendor = \HivePress\Models\Vendor::query()->filter(
			[
				'status' => [ 'auto-draft', 'draft', 'publish' ],
				'user'   => get_current_user_id(),
			]
		)->get_first();
		
		if(!$vendor->get_your_attribute_field_name()){
			$errors[] = 'Please set attachment';
		}
		
		return $errors;
	},
	1000,
	2
);

If you want to make the profile image required to show the Complete Profile page then please try this PHP snippet

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

		return $form;
	},
	1000
);

add_filter(
	'hivepress/v1/models/vendor/fields',
	function ($fields, $vendor){
		$fields['image']['required'] = true;
		
		return $fields;
	},
	1000,
	2
);

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