Change the default start/end time for new Community events

Home Forums Calendar Products Community Events Change the default start/end time for new Community events

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1020553
    Sean
    Participant

    We are using the code from your Change the default start/end time for new events article and it works great within the WP-admin! However, it doesn’t appear this has any effect on the Community Event’s Submit an Event form. Would you be able to share how this snippet can be modified to apply to that product as well? Thanks!

    #1020831
    Nico
    Member

    Hi Karly,

    Glad to help you once again here 🙂

    To change the start and end times of the community events submission template:

    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( 'today 5pm' );

    $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( 'today 7pm' );

    $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;
    }

    Include this snippet in your functions.php file and change the value for $new_time inside both functions. That should do the trick for you!

    Please give it a try and let me know,
    Best,
    Nico

    #1020938
    Sean
    Participant

    Hi again Nico,

    This is exactly what I needed and it works perfectly. Thank you so much for taking the time to put this together. Hopefully this will help others who want to change the start/end time on Community Events as well 🙂

    Have a great day!

    #1021254
    Nico
    Member

    Stocked to hear Karly!

    Have a great day yourself 🙂

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Change the default start/end time for new Community events’ is closed to new replies.