Send notification email to different addresses based on event location?

Home Forums Calendar Products Community Events Send notification email to different addresses based on event location?

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #1161841
    Teresa
    Participant

    Hi – my client has a cross-border tourism site and the USA calendar events are moderated by one person and the CAN ones by another. Right now they both get email notification for all submissions and have to open every single one to see if it’s in their area. Is it possible to direct the notifications for US events to one email address, and for Canadian events to another?

    #1162175
    Nico
    Member

    Hi Teresa,

    Thanks for getting in touch with us! Interesting request by the way!

    I was taking a look to the Community Events code, and found that the default alerts can’t be modified to insert this country check unfortunately. So I guess the way to go would be to deactivate default notifications and add a custom notifications function.

    Can you please link me to the community submission form in the site? I just want to check the country options you have to emulate those when I prepare the snippet for you.

    Best,
    Nico

    #1162291
    Teresa
    Participant

    Hi! The form is here: http://route97.net/events/public/add
    We only have US and Canada as country options – that’s all there will ever be. It could also be by prov/state, as there are only WA and BC options. The site is about a specific tourism region that goes only in those 2 areas, so it won’t be changing to add more provinces or states.
    Thanks!
    Teresa

    #1163157
    Nico
    Member

    This reply is private.

    #1163158
    Teresa
    Participant

    This reply is private.

    #1164248
    Nico
    Member

    Hey Teresa,

    Here’s the snippet to create a custom notification and change the email depending on the country:

    /* Tribe, custom Comminity notifications */
    function tribe_send_custom_ce_alert ( $tribe_event_id ) {

    $country = tribe_get_country ( $tribe_event_id );

    $email = '[email protected]';

    if ( 'United States' == $country ) {
    $email = '[email protected]';
    }

    $post = get_post( intval( $tribe_event_id ) );

    $subject = sprintf( '[%s] ' . __( 'Community Events Submission', 'tribe-events-community' ) . ':', wp_specialchars_decode( get_bloginfo( 'name' ), ENT_QUOTES ) ) . ' "' . $post->post_title . '"';

    // Get Message HTML from Email Template
    ob_start();
    include Tribe__Events__Templates::getTemplateHierarchy( 'community/email-template' );
    $message = ob_get_clean();

    $headers = array( 'Content-Type: text/html' );
    $h = implode( "\r\n", $headers ) . "\r\n";

    wp_mail( trim( $email ), $subject, $message, $h );

    }

    add_action ( 'tribe_community_event_created', 'tribe_send_custom_ce_alert' );

    Just paste the code above in your theme’s (or child theme’s) functions.php file and let me know fi it works for you. Please note that you can leave the default plugin notice active if you want.

    Best,
    Nico

    #1173290
    Support Droid
    Keymaster

    Hey there! This thread has been pretty quiet for the last three weeks, so we’re going to go ahead and close it to avoid confusion with other topics. If you’re still looking for help with this, please do open a new thread, reference this one and we’d be more than happy to continue the conversation over there.

    Thanks so much!
    The Events Calendar Support Team

Viewing 7 posts - 1 through 7 (of 7 total)
  • The topic ‘Send notification email to different addresses based on event location?’ is closed to new replies.