• Resolved inkform

    (@inkform)


    Is it possible to set the Notification Sender Address to the person’s email that is booking the event? I had hoped something like #_BOOKINGEMAIL would work, but it fails. Thank you.

Viewing 10 replies - 16 through 25 (of 25 total)
  • Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    RIGHT! Rotten backticks. ?? I suggest pastebin.com then.

    Why remove my link? I’ve used it before. Never been removed.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Because too many people have used these support forums to drive traffic back to their site. That’s not saying you are doing that, but that’s how it is so please don’t do that.

    Here I’ve done it for you: https://pastebin.com/7XV7vDF8

    That is exactly why I do not want to use pastebin: what you posted is incomplete. ??
    I believe the forum needs to be updated to posting code works much better than it does now…

    Thread Starter inkform

    (@inkform)

    Hey, Patrick

    Again, thank you for such diligence on this. We are setting up the SMTP now (were using PHP mail before) and then I’m going to test this out. I’ll keep you updated. Cheers.

    I have changed it a bit, so the code is shorter and better ??

    Step 1:
    In wp-content/events-manager/classes/em-mailer.php add this to line 99 (just above $send = $mail->Send();)
    do_action('em_mailer_before_send', $mail);

    Step 2:
    Add this snippet to your functions.php:

    function stonehenge_em_email_replyto( PHPMailer $mail ) {
    	global $EM_Booking;
    	$recipients = $mail->getToAddresses(); // Allows access to protected array.
    
    	// If is new booking with online payment.
    	if(!is_object($EM_Booking)) {
    		global $wpdb;
    		$table = EM_TRANSACTIONS_TABLE;
    		$transaction_id = $_REQUEST['id'];
    		$booking_id = $wpdb->get_var("SELECT booking_id FROM {$table} WHERE transaction_gateway_id= {$transaction_id}");
    		$EM_Booking = em_get_booking(esc_attr($booking_id));
    	}
    
    	// Only target Admin Emails.
    	if( !in_array($EM_Booking->get_person()->user_email, $recipients[0]) ) {
    		$mail->AddReplyTo( $EM_Booking->get_person()->user_email );
    	}
    	return;
    }
    add_action('em_mailer_before_send', 'stonehenge_em_email_replyto', 10, 1);
    

    Enjoy! ??

    Thread Starter inkform

    (@inkform)

    Awesome. Looking forward to trying this… as soon as I can get the SMTP emails to send. I’ve wandered into a whole new nightmare of “SMTP connect() failed.” Haha.

    Make sure your settings are correct. They should likely be the same as your normal email. Check your provider if they have not blocked it. ??

    Thread Starter inkform

    (@inkform)

    Got it. Turns out GoDaddy (our host) makes you jump through a few hoops to get it right.

    Oh, because you are sending HTML emails, it is a good idea to add a plain text version as well. That will reduce the chance of your email being marked as spam, dramatically. ??

    #===============================================
    # 	Add Plain Text version to EM Email.
    #===============================================
    function stonehenge_em_email_plaintext( PHPMailer $mail ) {
    	$body 	= $mail->Body;
    	$plain 	= str_replace("<br>","\n", $plain);
    	$plain 	= strip_tags($plain);
    	$mail->AltBody = $plain;
    }
    add_action('em_mailer', 'stonehenge_em_email_plaintext', 10, 1);
    
Viewing 10 replies - 16 through 25 (of 25 total)
  • The topic ‘Set Notification Sender Address as Booking Email’ is closed to new replies.