Hi there!
Other than categories (where a user can only choose one category) for tags the user can choose infinite or none at all.
Is there a way to set a minimum (eg 1) and a maximum (eg 3)? Now the user has to choose at least one and is able to choose up to three tags.
Is this possible?
Thank you
yevhen
2
Please try this PHP snippet
add_filter(
'hivepress/v1/models/listing/attributes',
function ($attributes){
if(isset($attributes['tags'])){
$attributes['tags']['edit_field']['max_values'] = 3;
}
return $attributes;
},
1000
);
add_filter(
'hivepress/v1/forms/listing_update/errors',
function ($errors, $form){
if(count((array)$form->get_value('tags')) < 1){
$errors[] = 'Please set at least one tag';
}
return $errors;
},
1000,
2
);
system
Closed
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.