Set a minimum and maximum limit for the amount of files uploaded to a listing

Hi!

I would like to set a limit of three and a maximum of twelve images per listing. So a vendor/host should only be able to upload three to twelve images, not less and not more. Is there a way to do that?

Thank you

Please try this PHP snippet to set the minimum number of images per listing

add_filter(
	'hivepress/v1/forms/listing_update/errors',
	function( $errors, $form ) {
		$listing = $form->get_model();
		
		if ( $listing && count($listing->get_images__id()) < 3 ) {
			$errors[] = 'Please upload at least three images.';
		}

		return $errors;
	},
	100,
	2
);

Please try this PHP snippet to set the maximum number of images per listing Change the maximum number of images per listing #hivepress #listings · GitHub

1 Like

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