Default email containing details about what has been moderated - not working properly

I have added it so, when attributes / content of a listing is changed, it requires a new approval/moderation before it is published again.

The default notification-email template that is sent to my admin email address contains the following content:
Listing "%listing_title%" %listing_url% has been updated with the following details: %listing_attributes%.

When I for example edit the pricing field of the listing, the email sent with a value of the %listing_attributes% is not returning the proper attribute that was changed. The email returns this string: “Listing “creating a website” www.inserturlhere.com has been updated with the following details: Pictures” ↔ when it clearly should have said “Price”.

Hi,

We checked this issue from our side, and it seems okay.

Please check your customizations in more detail; most likely, the issue is in them (or try disabling customizations and see if the problem persists).

I have done some debugging and I have found the problem to be in this code, more spesific, the image part.

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

		return $form;
	}
);

The problem is that no matter what change I make to the listing, it thinks that the images was changed, so it will always require moderation with the “Listing “creating a website” www.inserturlhere.com has been updated with the following details: Pictures”

If I change nothing:
…has been updated with the following details: Pictures

If I change description:
…has been updated with the following details: Pictures, Description.

If I change title and description:
…has been updated with the following details: Pictures, Title, Description.

I need a clean way to require moderation for altering the listings picture, because somehow, the snippet posted with “images” line breaks it, requireing moderation no matter what

update The same problem occures when trying to make tags require moderation

$form['fields']['tags']['_moderated'] = true;

Btw. Found this post from october 22. Seemes to be a know issue, but hasn’t been fixed yet:

“… Yes, there’s a known issue with the attachment attributes marked as Moderated, they send listings to Pending status even without changes - we’ll try to fix this as soon as possible.”

Yes, attachment fields are a bit specific, it’s not possible to enable moderation for them this way. Another approach is using the hivepress/v1/forms/listing_update/errors filter hook to add custom validation logic and throw errors.

Would it be possible to use that filter to add moderation on change or update of the images, or did I misunderstand?

Can you show me an implementation of it?

I think it would be important to have the moderation function connected to the images.

Yes, if you’re familiar with coding please try using the suggested filter, it accepts 2 parameters: the errors array and the form object. You can get listing from the form object:

$form->get_model();

And then check any listing details and add custom errors to the errors array. You can check a sample snippet here How to set up max tags users can choose - #3 by andrii

Wouldn’t returning an error just prevent the vendor from updating their listing information? I don’t see how this method will put the listing into draft status, requiring aproval from a moderator or admin.

Yes, sorry for the confusion, in this case you’d have to use the hivepress/v1/models/listing/update action hook, to check if images changed and switch the listing status to “pending”, also notifying the site admin using wp_mail

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