Draft Events in Frontend

Home Forums Calendar Products Events Calendar PRO Draft Events in Frontend

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1429219
    Davide
    Participant

    Hi there

    I’m willing to show the events in the draft status also in the month grid in the frontend: the purpose is to allow people to choose dates for their events in our territory being informed about already confirmed events (“published”) but also under construction events (“drafts”). I’ll definitely use your Community and Pro version for this purpose…

    Fact is, I want everything to happen in the frontend. I thought of editing /src/Tribe/Templates/Month.php lines 381-399 as follows, but I see private events as before, but no draft events… Am I missing something?

    protected function set_args( $args = array() ) {

            $doing_ajax = ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ? true : false;
    
            if ( empty( $args ) && $doing_ajax ) {
                $post_status = array( 'publish' );
                if ( is_user_logged_in() ) {
                    //EDITED WITH "DRAFT" $post_status[] = 'private';
                    $post_status[] = 'private, draft';
                }
                // set the global query var for eventDisplay
                $args = array(
                    'post_type'    => Tribe__Events__Main::POSTTYPE,
                    'eventDisplay' => 'month',
                    'eventDate'    => $_POST['eventDate'],
                    'post_status'  => $post_status,
                    'featured'     => tribe( 'tec.featured_events' )->featured_events_requested(),
                );
            }
    

    I thought of using “Private” status instead of draft, but I’d like to see the events automatically when published by Organizers through Community.

    Any ideas? Thanks a lot!

    #1430401
    Andras
    Keymaster

    Ciao Davide,

    Thanks for using our plugins and welcome to the forums!

    Awesome question! I might be able to help.

    The ‘$post_status’ is an array, so you need to provide separate elements to it and not a comma separated list.

    In the middle try this:
    if ( is_user_logged_in() ) {
    //EDITED WITH "DRAFT" $post_status[] = 'private';
    $post_status[] = 'private';
    $post_status[] = 'draft';
    }

    I believe that should do the trick. Let me know.

    Cheers,
    Andras

    #1431244
    Davide
    Participant

    Tried that, but nothing seems to happen… The cose is as follows:
    if ( empty( $args ) && $doing_ajax ) {
    $post_status = array( ‘publish’ );
    if ( is_user_logged_in() ) {
    //MODIFICATO CON DRAFT $post_status[] = ‘private’;
    $post_status[] = ‘draft’;
    }
    I removed “private” since I’m only interested in drafts. Any ideas about
    the reason so that I can keep working on it?
    Thanks a lot for your support!

    Mail
    priva di virus. http://www.avg.com

    Ai sensi dell’Art. 13 del D. LGS 196/2003, le informazioni contenute in
    questo messaggio di posta elettronica e negli eventuali allegati sono
    riservate ai destinatari.
    Persone o soggetti diversi dai destinatari stessi non sono autorizzate a
    leggere, copiare, modificare, diffondere il messaggio a terzi.
    Qualora un messaggio venisse ricevuto per errore, chiediamo cortesemente al
    soggetto che lo ha ricevuto di darcene notizia a mezzo e-mail e di
    distruggere il messaggio ricevuto erroneamente.

    #1432133
    Andras
    Keymaster

    Hi Davide,

    I’ll try to take a look at this custom query. At the moment we are overloaded in the help desk, so it might take a day or two.

    Thanks for your patience!

    Cheers,
    Andras

    #1433956
    Andras
    Keymaster

    Ciao,

    A colleague of mine was kind enough to take a look at this customization.

    He came up with the following snippet. Copy it into your functions.php and check if it does the trick.

    function modify_month_query( $query ) {
    global $wpdb;
    $query = str_replace(
    "$wpdb->posts.post_status IN('publish',",
    "$wpdb->posts.post_status IN('publish','draft',",
    $query
    );
    remove_filter( 'query', 'modify_month_query' );
    return $query;
    }
    function listen_for_month_query( $passthru ) {
    add_filter( 'query', 'modify_month_query' );
    return $passthru;
    }
    function unrestrict_month_view_post_statuses( $args ) {
    $args['post_status'] = 'any';
    return $args;
    }
    add_filter( 'tribe_events_month_get_events_in_month', 'listen_for_month_query' );
    add_filter( 'tribe_events_month_daily_events_query_args', 'unrestrict_month_view_post_statuses' );

    Cheers,
    Andras

    #1453028
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Draft Events in Frontend’ is closed to new replies.