Home › Forums › Calendar Products › Community Events › Send notification email to different addresses based on event location?
- This topic has 7 replies, 4 voices, and was last updated 7 years, 7 months ago by Teresa.
-
AuthorPosts
-
September 8, 2016 at 6:52 pm #1161841TeresaParticipant
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?
September 9, 2016 at 11:10 am #1162175NicoMemberHi 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,
NicoSeptember 9, 2016 at 3:37 pm #1162291TeresaParticipantHi! 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!
TeresaSeptember 12, 2016 at 7:21 pm #1163157NicoMemberThis reply is private.
September 12, 2016 at 7:24 pm #1163158TeresaParticipantThis reply is private.
September 14, 2016 at 2:27 pm #1164248NicoMemberHey 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,
NicoOctober 6, 2016 at 9:35 am #1173290Support DroidKeymasterHey 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 -
AuthorPosts
- The topic ‘Send notification email to different addresses based on event location?’ is closed to new replies.