Need to copy selected Category as Title

Hi Team,

We have a specific use-case where we want the Title of the Listing to be the same as the Category.
So, when a vendor is creating a listing, we want this to happen on the fly i.e. when the Vendor selects from the Category dropdown, the Title should get auto-populated with the same value as the selected Category.

We tried writing a code snippet, however it did not work. Can you please help us out?

function assign_category_to_title($form) {
    $value = '';

    add_filter('hivepress/v1/forms/listing_submit', function($form) use (&$value) {
        $value = $form['fields']['categories']['value'];
        return $form;
    }, 1000);

    add_filter('hivepress/v1/forms/listing_update', function($form) use (&$value) {
        $form['fields']['title']['value'] = $value;
        return $form;
    }, 1000);

    return $form;
}

// Apply the filters within the function
add_filter('hivepress/v1/forms/listing_update', 'assign_category_to_title');

Thanks,
Team Purohit Connect

Hi,

Sorry, there’s no simple code snippet for this, it would require a custom implementation. If customizations beyond the available features are required for your site, please consider hiring someone for custom work https://fvrr.co/32e7LvY

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.