Skip to content

Instantly share code, notes, and snippets.

@hivepress
Last active February 13, 2025 17:21
Show Gist options
  • Save hivepress/b20578496b8ba97d4de31375d9495497 to your computer and use it in GitHub Desktop.
Save hivepress/b20578496b8ba97d4de31375d9495497 to your computer and use it in GitHub Desktop.
Require uploading at least one image for listings #hivepress #listings
<?php
add_filter(
'hivepress/v1/forms/listing_update/errors',
function( $errors, $form ) {
$listing = $form->get_model();
if ( $listing && ! $listing->get_images__id() ) {
$errors[] = 'Please upload at least one image.';
}
return $errors;
},
100,
2
);
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
$form['fields']['images']['statuses']['optional'] = null;
return $form;
},
1000
);
@Tetramagon
Copy link

Tetramagon commented Sep 2, 2024

it works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment