Require moderation when making changes to the images

I want to pull down a listing when a vendor makes changes to the images uploaded, so that a moderator has to approve the listing again.

add_filter(
	'hivepress/v1/forms/listing_update',
	function( $form ) {
		$form['fields']['title']['_moderated'] = true;
		$form['fields']['description']['_moderated'] = true;
        $form['fields']['image']['_moderated'] = true;

		return $form;
	}
);

The mentioned php snippet does this, to some extent, but I have issues when adding the image part, that the front end listing-form adds an input field with no desciption or placeholder.

When inspecting the element it is a div with a class of hp-form__field hp-form__field–id" and an input with a class of hp-field hp-field–id.

What is the correct way to implement this?

Please try using the hivepress/v1/models/listing hook instead, this should resolve the field display issue.

I’ll try. Is this the preferred Hook for the other fields aswell?

This depends on the required changes, e.g. if something is related to the field display or a specific form (not the listing model in general) it’s better to use the form hooks.

I see.

In any case, the suggested hook diddn’t make a different. It diddn’t require moderation when a user removes or uploads a new image. Do you have any other suggestion?

Preferably, I’d only like to moderate when a user uloads a new image to their listing, not when they delete an excisting picture, since I already require one image, and they cannot delete the last, theres no sence in moderating when they remove some images.

Please try this PHP snippet instead to make image field required moderation. The problem in your code snippet was that you use image instead of images for listings

add_filter(
	'hivepress/v1/forms/listing_update',
	function( $form ) {
		$form['fields']['images']['_moderated'] = true;

		return $form;
	}
);

This works now. I was certain that I did try that first, but oh well.

Thank you

1 Like