Reccomended way to modify template function content

What would be the recommended way to change default functions for things like printing the event dates or any other public functions.

Example: get_event_dates will print

On October 9, 2015 from 11:05 pm to October 10, 2015 12:05 am
how would you modify outside the plugin o print like
10/09/2015 @ 11:05pm - 10/10/2015 12:05am

This is just a demo for demos sake, really looking for the recommended way to do this on any sort of printed text function.

  • Vinod Dalvi

    Hi @brettlewis,

    I hope you are well today and thank you for your question.

    Basically we have to avoid editing anything in the plugin code till there isn't any other option to do because if you are making changes in the plugin file then you have to make these changes again after plugin updation as changes made in the plugin file get lost on plugin updation.

    So to change the output provided by the plugin function get_event_dates you can use the filter hook event_date_string provided in it as following.

    $content .= apply_filters('eab-events-event_date_string', "<time itemprop='startDate' datetime='{$time_date_start}'>{$start_string}</time> <time itemprop='endDate' datetime='{$time_date_end}'>{$end_string}</time>", $event->get_id(), $start, $end);

    Best Regards,
    Vinod Dalvi

  • Kasia Swiderska

    Hello brettlewis,

    In what file did you try to use this filter? I'm attaching sample piece of code of how it should be used in the functions.php

    if(!function_exists('wpmu_custom_events_date_format')){
    function wpmu_custom_events_date_format($content, $id, $start_date, $end_date){
    
    			$time_date_start = '12.12.12';
    			$time_date_end = '15.15.15';
    			$start_string = '12.08.2015';
    			$end_string = '85.28.1025';
    
    		return "<time itemprop='startDate' datetime='{$time_date_start}'>{$start_string}</time> <time itemprop='endDate' datetime='{$time_date_end}'>{$end_string}</time>";
    }
    
    add_filter('eab-events-event_date_string', 'wpmu_custom_events_date_format', 10 , 4);
    }

    As you could see I just put there only strings in the variables, but there should be date of event in new format that you need. But basically this is how to override standard date formats.
    Here is another sample of code (this is other function) but you will see how to work with this https://premium.wpmudev.org/forums/topic/event-rsvp-shortcode-or-way-to-output-rsvp-button-for-specific-event#post-777165

    Kind regards,
    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.