• Resolved publicradio

    (@publicradio)


    I’m building a site for an organization with pretty consistent dates and times. If their events are always 4-6 pm, can I have this be the default for events?

    And for recurring events, if they’re always Friday, Saturday and Sunday from 4-6, can I have this be the default for recurring?

    I know there’s a pastebin where you can set defaults for tickets, so I assume this can be done with events.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Support angelo_nwl

    (@angelo_nwl)

    I’m afraid that this is not possible out of the box at the moment.

    Thread Starter publicradio

    (@publicradio)

    Thanks for the reply. This code will work, in functions.php or a plugin:

    
    add_action( 'admin_footer', function(){
    ?>
        <script type="text/javascript">
            jQuery('#start-time').val("6:00 PM");
            jQuery('#end-time').val("9:00 PM");
        </script>
    <?php
    });
    

    Maybe a little hacky, but it gets the job done.

    By the way, I noticed when I was working on this that those start and end time dropdowns are supposed to be jQuery Timepickers. I tried to reinitialize them, but the standard dropdowns were showing up on top of the time pickers. If you are able to re-implement them, it’s probably an easy fix.

    TreeTrail

    (@aprilschmitt27)

    @publicradio: This seems to work great. Thank you very much for sharing!

    EM Support: Do you see any problem with us utilizing this solution in our Child/Functions.php file?

    ~April

    Just chipping in my opinion here ??
    @publicradio’s solution works but is not save (enough). It will always put the values to these new ones. So if you ever have an event with different times, you have to change it back manually every time you open the Edit Event Page.

    To only target new (unpublished) events:

    add_action( 'admin_footer', function() {
    	global $post;
    	// Only target new Edit Event pages.
    	if( $post->post_type === 'event' && $post->post_status != 'publish' ) {
    		?><script type="text/javascript">
    			jQuery('#start-time' ).val('06:00 PM');
    			jQuery('#end-time').val('09:00 PM');
    		</script><?php
    	}
    }, 15);

    Also, lower the priority, just to make sure jQuery is indeed loaded. ??

    TreeTrail

    (@aprilschmitt27)

    Thank you very much @duisterdenhaag. This is very important and I really appreciate your advice!

    EM staff, this topic is resolved for me.

    Glad to help ??

    If you are like me and get goosebumps upon every EM datepicker (the enormous year range) and the 15 minute time step in the time picker (I do night tours so I keep scrolling down), here’s an examples to change those options:

    function em_change_picker_vars() {
    	?>
    	<script type="text/javascript">
    		jQuery(document).bind('em_datepicker', function( e, em_datepicker ){
    			em_datepicker.yearRange = '-1:+3';
    		});
    
    		jQuery(document).bind('em_timepicker_options', function( e, em_timepicker ){
    			em_timepicker.step = 30;
    			em_timepicker.startTime = '09:00';
    			em_timepicker.endTime = '22:00';
    			em_timepicker.show24Hours = true;
    		});
    	</script>
    	<?php
    }
    add_action('admin_footer','em_change_picker_vars', 20);

    Just a warning:
    the .bind() function has been depreciated, so it might need some updating. But then again. EM still uses this timepicker: https://github.com/perifer/timePicker
    That has not been maintained for over 9 years!

    On my personal system I have replaced it with this great timepicker: https://github.com/jonthornton/jquery-timepicker.

    Ehm… To make it completely save, I’ve created a custom template. EM will automatically find it, if it’s in the correct directory.

    It also cleans up the layout of dates & times. ??
    Here’s the code:
    https://pastebin.com/jWg9SXhu

    Go to Plugins–> Plugin Editor
    Select Events Manager
    Directory “Classes”
    Select em-event.php

    Line 78 and Line 74-
    protected $event_start_time = ’00:00:00′;
    protected $event_end_time = ’00:00:00′;

    Those are your defaults

    @noctividus, any update of EM will remove those changes, because you are editing the core file. ??

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Set default times for events’ is closed to new replies.