This is OK, however, a user can abuse the images/attachments upload sections. Any user can edit their listing, upload nudity/inappropriate files and leave the page without clicking “Save Changes”. The media/attachment is immediately applied and visible on the frontend on published listings. The admins are never notified of these changes due to the user never “saving” the listing.
What’s the solution to this? How do I stop this from happening?
The uploader is a separate component from the form, since the file upload process is handled independently.
Please use the following snippet to send listings to moderation once the image has been uploaded:
add_action(
'hivepress/v1/models/listing/update_image',
function ( $listing_id, $value ) {
$listing = \HivePress\Models\Listing::query()->get_by_id( $listing_id );
// Only update if the listing is currently published
if ( $listing && $listing->get_status() === 'publish' ) {
$listing->set_status( 'pending' )->save_status();
}
},
1000,
2
);
Unfortunately, there is no simple solution for this scenario. The main challenge is that we would need to “wait” and detect when the user has uploaded the final image. This is not trivial because it requires tracking uploads over time and determining when the upload sequence is complete, which is difficult to define reliably in practice.
Triggering a pending state after every uploaded image would not be a good approach, as it could lead to unnecessary moderation events and a poor user experience.
In general, this would require a more advanced implementation where uploads are counted over a short time window and only then processed as a single batch.
For now, we can only provide general developer guidance on which hooks are triggered during the upload process.
Thank you. I have worked around it by sending the post to Draft if images and attachments are updated, then to Pending when the listing is submitted again.