Default start/end times for community events

Home Forums Ticket Products Community Tickets Default start/end times for community events

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1317259
    anywherefest
    Participant

    I am using the snippet provided by Nico to change the start/end times for community events but it isn’t working- can you help?

    add_action( ‘tribe_community_events_form_start_time_selector’, ‘comm_default_start_time’, 10, 2 );
    function comm_default_start_time( $output, $event_id ) {

    if ( !$event_id ) {

    $new_time = strtotime( ‘7:30pm’ );

    $start_date = tribe_event_format_date( $new_time, true, Tribe__Events__Date_Utils::DBDATETIMEFORMAT );

    $start_minutes = Tribe__Events__View_Helpers::getMinuteOptions( $start_date, true );
    $start_hours = Tribe__Events__View_Helpers::getHourOptions( $is_all_day == ‘yes’ ? null : $start_date, true );
    $start_meridian = Tribe__Events__View_Helpers::getMeridianOptions( $start_date, true );

    $output = ”;
    $output .= sprintf( ‘<select name=”EventStartHour”>%s</select>’, $start_hours );
    $output .= sprintf( ‘<select name=”EventStartMinute”>%s</select>’, $start_minutes );
    if ( ! tribe_community_events_use_24hr_format() ) {
    $output .= sprintf( ‘<select name=”EventStartMeridian”>%s</select>’, $start_meridian );
    }
    }

    return $output;
    }

    add_action( ‘tribe_community_events_form_end_time_selector’, ‘comm_default_end_time’, 10, 2 );
    function comm_default_end_time( $output, $event_id ) {

    if ( !$event_id ) {

    $new_time = strtotime( ‘8:30pm’ );

    $start_date = tribe_event_format_date( $new_time, true, Tribe__Events__Date_Utils::DBDATETIMEFORMAT );

    $start_minutes = Tribe__Events__View_Helpers::getMinuteOptions( $start_date, true );
    $start_hours = Tribe__Events__View_Helpers::getHourOptions( $is_all_day == ‘yes’ ? null : $start_date, true );
    $start_meridian = Tribe__Events__View_Helpers::getMeridianOptions( $start_date, true );

    $output = ”;
    $output .= sprintf( ‘<select name=”EventStartHour”>%s</select>’, $start_hours );
    $output .= sprintf( ‘<select name=”EventStartMinute”>%s</select>’, $start_minutes );
    if ( ! tribe_community_events_use_24hr_format() ) {
    $output .= sprintf( ‘<select name=”EventStartMeridian”>%s</select>’, $start_meridian );
    }
    }

    return $output;
    }

    #1317752
    Patricia
    Member

    Hey Alex,

    Thanks for contacting us.

    This snippet you are trying to implement was written in 2015 and our code base has changed since then. We will review this snippet and get back to you as soon as we have further information!

    Let us know if you need anything else in the mean time and have a great weekend!

    Regards,

    Patricia

    #1317777
    anywherefest
    Participant

    Thanks Patricia- I look forward to hearing from you.

    #1318394
    Patricia
    Member

    Hey Alex,

    Please add this snippet to your functions.php file:

    https://gist.github.com/nefeline/aceabe1f914a0583340396d25c0b2308

    This code will update the default time for both The Events Calendar and  Community Events.

    Let me know if this works for you or if you need anything else and I’ll be happy to assist!

    Regards,

    Patricia

    #1319181
    anywherefest
    Participant

    It works perfectly Patricia- thank you!

    #1319217
    Patricia
    Member

    Hi Alex,

    Good to know that it worked as expected!

    Let me know if you need anything else and have a great week! 🙂

    Regards,

    Patricia

    #1328874
    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 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Default start/end times for community events’ is closed to new replies.