Okay
  Public Ticket #3008460
Set up options in Backend
Closed

Comments

  •  5
    joshivince started the conversation

    Dear Zhivko,

    is it possible to set in every event two options as default:

    Under STEC > Events > Edit Event > Tab General: There I want to have the options "Counter" and also "Comments" set as default active.

    Until now I have to set both options manually on active at every new entry.

    Thanks in advance,
    Vincent

  •  877
    Zhivko replied

    You could use this hook:

    add_action('stec_after_insert_event', function ($result, $event, $is_update) {
        if ($is_update) {
            return; // do nothing if is update
        }     wp_update_post(array(
            'ID'             => $event->get_id(),
            'comment_status' =>  'open',
            'meta_input'     => array(
                'comments' => 1         )
        )); }, 10, 3);

    This will make sure to open comments regardless of the admin settings ONLY when you create the event for the first time meaning you can close the comments if you update the event afterwards.

    The hook should be placed in your theme or child-theme functions.php file.


    Stachethemes Developer

  •  5
    joshivince replied

    Thank you, Zhivko.

    Is that also working for the Counter? I think this code is for the comments only?

    With "Counter" I mean the count down of the days remaining until the event happens. See screenshot attached.

    Thanks again,

    Vincent

  •  877
    Zhivko replied

    Sorry... here's updated code.

    add_action('stec_after_insert_event', function ($result, $event, $is_update) {
    
        if ($is_update) {
            return; // do nothing if is update
        }
        wp_update_post(array(
            'ID'             => $event->get_id(),
            'comment_status' =>  'open',
            'meta_input'     => array(
                'comments' => 1,
                'counter' => 1,
            )
        ));
    }, 10, 3);



    Stachethemes Developer

  •  5
    joshivince replied

    Dear Zhivko,
    it works perfekt. Thanks a lot.

    This ticket can be closed.

    Really nice and also fast support. Thanks for that!

    Vincent