Home › Forums › Calendar Products › Events Calendar PRO › Draft Events in Frontend
- This topic has 6 replies, 2 voices, and was last updated 6 years, 2 months ago by Davide.
-
AuthorPosts
-
January 18, 2018 at 1:58 am #1429219DavideParticipant
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!
January 19, 2018 at 5:10 am #1430401AndrasKeymasterCiao 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,
AndrasJanuary 19, 2018 at 11:45 pm #1431244DavideParticipantTried 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.comAi 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.January 22, 2018 at 3:27 am #1432133AndrasKeymasterHi 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,
AndrasJanuary 23, 2018 at 12:51 pm #1433956AndrasKeymasterCiao,
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,
AndrasFebruary 14, 2018 at 8:36 am #1453028Support DroidKeymasterHey 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 -
AuthorPosts
- The topic ‘Draft Events in Frontend’ is closed to new replies.