Hi, @ihor! How it’s going? Please, tell me, how I can modify this code (works well for listings) to generate a title for requests from requests attributes? Thank you!
add_action(
'hivepress/v1/models/listing/update',
function ($listing_id) {
$listing = HivePress\Models\Listing::query()->get_by_id($listing_id);
if ($listing) {
$title = null;
if ($listing->get_room__id()) {
$title .= $listing->display_otaq();
}
if ($listing->get_metro__id()) {
$title .= ', ' . $listing->display_metro() . ' yanı';
}
if ($listing->get_title() !== $title) {
$listing->set_title($title)->save_title();
}
}
},
1000
);
add_filter(
'hivepress/v1/models/listing',
function ($model) {
$model['fields']['title']['required'] = false;
$model['fields']['title']['max_length'] = 512;
$model['fields']['title']['display_type'] = 'hidden';
return $model;
},
1000
);