Join our new community forum for support & discussion

Join Now

Home Support Extensions Requests Automatic title for requests

Automatic title for requests

  • Author
    Posts
  • emilgadzhiyev

    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
    );
    ihor developer

    Hi Emil,

    It may actually work if you just replace all “listing” occurrences with “request” in this code snippet. Also please make sure that it queries existing request attributes.

Viewing 2 posts - 1 through 2 (of 2 total)

New Reply

This forum has been archived and is no longer accepting new posts or replies. Please join our new community forum for support & discussion.