Home › Forums › Calendar Products › Community Events › Change the default start/end time for new Community events
- This topic has 3 replies, 2 voices, and was last updated 10 years, 5 months ago by
Nico.
-
AuthorPosts
-
October 31, 2015 at 7:10 pm #1020553
Sean
ParticipantWe 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!
November 2, 2015 at 8:18 am #1020831Nico
MemberHi 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,
NicoNovember 2, 2015 at 12:21 pm #1020938Sean
ParticipantHi 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!
November 3, 2015 at 7:21 am #1021254Nico
MemberStocked to hear Karly!
Have a great day yourself 🙂
-
AuthorPosts
- The topic ‘Change the default start/end time for new Community events’ is closed to new replies.
