Events Manager on Multisite With Unique “From” Email Per Subdomain

Events Manager on Multisite With Unique “From” Email Per Subdomain

Did you install Events Manager, or purchase Events Manager Pro for use on your multisite?  If so, you may have been surprised to learn that the From: email address and From: name are the same across your network of sites using the Events Manager plugin.

That sure is weird they would design their plugin to do this!

I found this out accidentally by activating Events Manager on a second subdomain, then got an email from my first client saying their “From” Email and Name had changed.  This was because I changed the settings for the second site, not realizing it also changed the settings for the first site.

Where’s Event Manager’s Email Settings?

I’m sure you’re asking:  “Where are these Email Settings in Events Manager?”

Events Manager Email Settings Screenshot

Well, by default the plugin authors deactivate these settings when Events Manager is active on a multisite network by wrapping this around the function that generates the Email Settings.

if( !is_multisite() ) { ... }

I only found this out by digging around the plugin code.  You can remove this extra conditional code by opening this file:

events-manager/admin/settings/tabs/emails.php on line 5.

Before:

if ( !is_multisite() ) { em_admin_option_box_email(); }

After:

em_admin_option_box_email();

That’s not all!  I thought I could just remove this conditional, edit my “From” Email and Name for each site, and life would be good.  This is actually a global setting for the entire network.  See for yourself by editing the Notification Sender Name and Notification Sender Address fields.  Visit another site on your network with Events Manager active, and you’ll see the same settings displayed.  Yikes!

How did I fix this?

I had to edit another plugin file directly, since there are no hooks for me to tab into.  Find and open this file in the plugin:

events-manager/classes/em-mailer.php

Since I already made the Email Settings viewable by removing the conditional above, I could see the Mail Sending Method select box.  By default, Events Manager uses the PHP mail function option.  I changed this to WP Mail and saved the settings.  Depending on your server configuration, you may need to choose a different option.  I’m hosting my  website with WP Engine, so using WP Mail worked fine for me.  I’ll tell you why I changed this setting in a little bit.

This file uses the function send() to send event emails.  Inside this function are all the “if”, “elseif” statements used for each type of Mail Sending Method.  Since I chose the WP Mail option in the Email Settings, we are looking in the part of the function where “dbem_rsvp_mail_send_method” == “wp_mail”, between lines 35-49.

We are looking to edit the $from variable and $headers variable, lines 36, 37.

I decided to use the Blog Site Title and Blog Email Address fields used under Settings > General as the “From” email and name.  You might not want to use these settings for your sites, but for my clients, using this title and email address is fine.

Before:

$from = get_option('dbem_mail_sender_address');
$headers = get_option('dbem_mail_sender_name') ? 'From: '.get_option('dbem_mail_sender_name').' <'.$from.'>':'From: '.$from;

After:

$from = get_bloginfo('admin_email');
$headers = get_bloginfo('name') ? 'From: '. get_bloginfo('name') .' <'. $from .'>' : 'From: '. $from;

After saving this these two changed files: emails.php and em-mailer.php, and uploading them via ftp or your preferred upload method, Events Manager will now use subdomain specific From Email and From Name by using each sites fields under Settings > General of the wordpress admin.

Why did I use WP_Mail?

Remember why I said I’d talk more about why I used wp_mail instead of the default Mail Sending Method?

The reason for me was for HTML emails.

I initially used the default PHP mail function option.  But when I tested an event, and received my event confirmation email, my fancy html email notification was regular text inside my Gmail account!  Not good.  I tried editing the html headers to ensure the email was read as html, not plain text like so: Content-type: text/html; charset=”UTF-8, but this still didn’t work.

So by trying the other option using WP Mail, the email was sent as an HTML email instead.  You may need to mess with these options based on your web host’s server.  These were the options that worked for me.

 

2016-10-28T19:12:34+00:00Plugin Hacks, Tips and Tricks|

About the Author:

My name is Jarel Culley and I am a freelance front-end web designer based in Bend, Oregon. I specialize in intuitive, easy to use and beautiful responsive websites for projects both large and small that work on any type and size of device. My work has a heavy leaning towards simplicity and typography with a gimmick free focus on content and concise communication.

Leave A Comment