Events Made Easy Forums How do I … Send mail on event PUBLISHING

Tagged: ,

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #61869
    501riders
    Participant

    Hey Franky….

    Using the code found in documentation at https://www.e-dynamics.be/wordpress/category/documentation/12-hooks-and-filters/

    add_action('eme_insert_event_action','eme_mail_event');
    function eme_mail_event ($event) {
       $contact = eme_get_event_contact ($event);
       $contact_email = $contact->user_email;
       $contact_name = $contact->display_name;
       $subject_format="This is the new event called ' #_EVENTNAME '";
       $body_format="This is the new event called ' #_EVENTNAME '";
    
       $subject=eme_replace_placeholders($subject_format, $event, "text");
       $body=eme_replace_placeholders($body_format, $event, "text");
       $blogusers = get_users();
       foreach ( $blogusers as $user ) {
          eme_send_mail($subject,$body, $user->user_email, $user->display_name, $contact_email, $contact_name);
       }
    }

    I am able to get the system to send mail the second I press SAVE. Unfortunately, some events are still drafts or are private and I don’t want them sending until they publish to the public at large.

    Any way to add a filter or hook to only send once published or, barring that, only send events that are in a certain category automatically?

    Thanks

    #61871
    Franky
    Keymaster

    Add this condition to your code:

    if ($event ['event_status'] == EME_EVENT_STATUS_PUBLIC)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.