Okay
  Public Ticket #2448101
Hide events
Closed

Comments

  •  1
    trinews started the conversation

    Is there a way to hide events. Events are stored but I don't want to show them at the calendar until they are approved.

    thanks

  •  877
    Zhivko replied

    Unapproved events are visible only to the admin. Users don't see them.


    Stachethemes Developer

  •  1
    trinews replied

    where to set status "unapproved"?

  •  877
    Zhivko replied

    Are those events created from the front-end?


    Stachethemes Developer

  •  1
    trinews replied

    No, those were imported via CSV (or added on the backend)

    Example:

    I want to add the events and all designs, but they shouldn't be online now. 

  •  877
    Zhivko replied

    I've written small extension that will add additional tab (Approve Status) in the admin add/edit event page with which you can set approval status.

    Place the code in your theme/child-theme functions.php file.

    add_action('stec_admin_addedit_event_tab', function() {
        printf('<li data-tab="approval">Approve Status</li>');
    }); add_action('stec_admin_addedit_event_tab_content', function($event) {     $status = isset($event) ? $event->get_approved() : 0;     echo '<div class="stachethemes-admin-section-tab" data-tab="approval">';
        echo '<p class="stachethemes-admin-info">Approval Status</p>';
        echo '<select class="stachethemes-admin-select" name="is_approved">';     printf('<option %s value="%d">%s</option>', (0 === $status ? 'selected' : ''), 0, esc_html__('Unapproved'));
        printf('<option %s value="%d">%s</option>', (1 === $status ? 'selected' : ''), 1, esc_html__('Approved'));     echo '</select>';
        echo '</div>';
    }); add_filter('stec_insert_post', function($data) {     if ($data['post_type'] !== 'stec_event') {
            return $data;
        }     if (filter_input(INPUT_GET, 'task', FILTER_DEFAULT) === 'approve') {
            return $data;
        }     $approved = filter_input(INPUT_POST, 'is_approved', FILTER_VALIDATE_INT);     $data['meta_input']['approved'] = $approved;     return $data;
    });


    We'll add this functionality by default in the next update.


    Stachethemes Developer

  •  1
    trinews replied

    Hey,

    thanks - amazing! It seems there is a bug with caching function. If caching is activated, the events are shown in the frontend with "AWAITING APPROVAL" for normal users. If caching is disabled, then the events are not shown. 

    Would be great to use caching and the new function ;-)

    thanks
    Stefan

  •  877
    Zhivko replied

    When events are modified you will have to purge the cache manually from the Cache menu.

    It's nuisance. I'll add optional auto-purge option in the cache menu in future update.


    Stachethemes Developer