I want tomake select an image fieldmandatory and if it possible I wouldliketo know how to to the same with name, surname etc.
The code below makes it required to have at least one image when creating a listing.
<?php
add_filter(
'hivepress/v1/forms/listing_update/errors',
function( $errors, $form ) {
$listing = $form->get_model();
if ( $listing && ! $listing->get_image__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
);
This one makes first and last name required. Add it with the code snippers plugin, or in your function.php file.
<?php
add_filter(
'hivepress/v1/forms/user_update',
function( $form ) {
$form['fields']['first_name']['required'] = true;
$form['fields']['last_name']['required'] = true;
return $form;
},
1000
);
3 Likes
Thank you, but is it possibletodo itwithout coding?
No. But just download the “code snippets” plugin and paste the code without the <?php tag
1 Like
Please try this PHP snippet to make the profile image required for users Make the profile image required for users #hivepress #users · GitHub
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.