• Resolved hahvensa

    (@hahvensa)


    Hi,
    I was wondering if it’s possible to send user a notification when his/hers event has ended the same way admin get’s notifications about published events.

    I guess the right template is em-emails.php and by copying part of that I may be able to create my own filter and function in my functions.php?

    Am I going to right direction with this? I need to find somehow if event has ended and then email the owner. This is not right and I probably need a different filter too, but maybe something like this?

    function em_event_ended_email($result, $EM_Event){
    if( $result ){
    	if( $EM_Event-> find out if event has ended? ){
    	if( $EM_Event->event_owner == "" ) return true; {
    		$subject = $EM_Event->output('Event has ended', 'raw');
    	    $body = $EM_Event->output(get_option('dbem_event_published_email_body'), $output_type);
    	    $EM_Event->email_send( $subject, $body, $EM_Event->get_contact()->user_email);
    	 }
    	}
    }
    return $result;
    }
    
    add_filter('em_event_save','em_event_ended_email',10,2);

    https://www.ads-software.com/extend/plugins/events-manager/

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hiya,

    What you’d probably need to do is register a scheduled even using WP Cron upon the saving of an event.

    What you have above will only trigger the e-mail when the event is saved, rather than at the actual end of the event.

    Hope that helps,
    Phil

    Thread Starter hahvensa

    (@hahvensa)

    OK, that sounds wise ?? So I need to tie the end date with event save or did I totally misunderstood?

    Would it be possible to check daily the events that have passed the end date with wp cron and then launch the email? Something like

    if( !wp_next_scheduled( 'event_end_date' ) ) {
       wp_schedule_event( time(), 'daily', 'event_end_date' );
    }  
    
    add_action( 'event_end_date', 'em_event_ended_email' );
    
    function em_event_ended_email() {
    	$subject = $EM_Event->output('Event has ended', 'raw');
    	$body = $EM_Event->output(get_option('Your event has ended'), $output_type);
    	$EM_Event->email_send( $subject, $body, $EM_Event->get_contact()->user_email);
    }

    But I’m not sure how to find if the event has passed the end date. Maybe the same way the is_past condition?

    if ($scope ='past';)

    Plugin Support angelo_nwl

    (@angelo_nwl)

    using php, try to compare the event date vs. the date today

    e.g.

    if ( $EM_Event->start <= current_time('timestamp')) {
    
    }
    or
    if ( $EM_Event->end <= current_time('timestamp')) {
    
    }

    Thread Starter hahvensa

    (@hahvensa)

    OK, this is the best I can get, not really working though, maybe some day ??

    wp_schedule_event( time(), 'hourly', 'event_end_date' );
    add_action( 'event_end_date', 'em_event_ended_email' );
    if ( $EM_Event->end <= current_time('timestamp')) {
    function em_event_ended_email() {
    	$subject = $EM_Event->output('Event has ended', 'raw');
    	$body = $EM_Event->output(get_option('Your event has ended'), $output_type);
    	$EM_Event->email_send( $subject, $body, $EM_Event->get_contact()->user_email);
    }
    }
    add_filter('event_end_date','em_event_ended_email');

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Notification when event ended’ is closed to new replies.