Hi, How can I make the titles of the listings have only Alphabets and symbols should be restricted?
Thanks
Hi, How can I make the titles of the listings have only Alphabets and symbols should be restricted?
Thanks
Hi,
Please use this PHP snippet:
add_filter(
'hivepress/v1/forms/listing_update',
function( $form ) {
if ( isset( $form['fields']['title'] ) ) {
$form['fields']['title']['pattern'] = '([a-zA-Z0-9_-]+)';
}
return $form;
},
1000
);
Also, please note that this is a sample code, and you may need to make additional changes to it.
Hi there Andrii
Just tested your snippet and I get error “Please match the requested format.”
I then added a space value to the allowed characters, [a-zA-Z0-9_- ] (space after the - character) but then get a different error “Title” field contains an invalid value.
The Listing Title I tried “Test Listing”
Is there maybe something else we’re missing?
@Abe it would be interesting to know if it works on your site.
Hi,
Please try this PHP snippet:
add_filter(
'hivepress/v1/models/listing',
function( $model ) {
if ( isset($model ['fields']['title'] ) ) {
$model['fields']['title']['pattern'] = '([a-zA-Z0-9_-]+)';
$model['fields']['title']['description'] = 'please use alphanumeric characters and numbers only';
}
return $model ;
},
1000
);
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.