Support

Home Forums Event Espresso Premium Modifyng the pre-approval confirmation email

Modifyng the pre-approval confirmation email

Posted: November 27, 2013 at 6:01 am

Viewing 39 reply threads


B D

November 27, 2013 at 6:01 am

I would like to slightly modify the pre-approval confirmation email that is automatically sent to attendees. I am aware that the template is hard coded in the event-espresso/includes/functions/email.php at around line 833.

My questions:
1. How do I make these changes so that they get not cancelled when updating EE?

2. I would like to add a couple more simple sentences to this email template. How to do this in php?

Thank you in advance for your help.

B D


Dean

November 27, 2013 at 6:29 am

Hi,

The Function is pluggable (http://codex.wordpress.org/Pluggable_Functions), meaning that you can copy the entire function to somewhere like the custom_functions.php file and it will work but not get over written.

To add more lines I would use the structure already in place, so where it says

$body .= sprintf( __('Attendee name: %1$s %2$s', 'event_espresso'), $fname, $lname );
			$body .= '<br/>';

I would copy and paste that below it and modify the sprintf content as per normal.

If you are not comfortable around PHP it is advisable to contact a developer regarding this.

It is not recommended to make these changes on a live site, one typo and the site will crash, until you can go in via FTP and rectify the error.


B D

November 27, 2013 at 7:19 am

Thank you Dean for such a prompt response.

I’m sorry for my ignorance in php matters, but

1. Where is exactly located the custom_functions.php file? Or should I create it? (and in this case where should I place it)?

2. If a wish to add a new sentence like “This is an automated message. Please do not reply”, is is right to add:

$body .= sprintf __(‘This is an automated message. Please do not reply’, ‘event_espresso’ );
$body .= ‘<br/>’;

Thank you in advance for your help.

B D


Sidney Harrell

November 27, 2013 at 9:48 am

You can add the code to one of the following:
1 – Your theme’s functions.php file. It may get overwritten the next time you update your theme.
2 – The EE custom files add-on in the custom_functions.php file.
3 – Use this blank plugin to hold the custom function.
The sprintf function is used to insert variables into the string. You could simplify it to:

$body .= ‘This is an automated message. Please do not reply.<br/>’;


B D

November 27, 2013 at 10:56 am

Thank you for the explanation. I’ll add the code in the functions.php file.

However, I would like to ask what is the exact code to add? (that is, from which line to which line of the event-espresso/includes/functions/email.php?)

Thank you again for your kind help.


Sidney Harrell

November 27, 2013 at 11:23 am

I’m looking at version 3.1.35.2.P, and the function starts at line 752 and goes to line 864, not counting the “if function exists” wrapper, which you don’t need to copy.
Where you put the new line in depends on where you want it to appear in the email. If you want it after the “Thank You” line, then it would look like this:

$body .= __('Thank You.', 'event_espresso');
$body .= ‘<br>This is an automated message. Please do not reply.’;


Sidney Harrell

November 27, 2013 at 11:27 am

Grrr. The forum software is stripping out the line break tags, even though they are wrapped in the code shortcode. Please insert them into the code to format the email in the desired fashion. Thanks.


B D

November 27, 2013 at 1:05 pm

Thank you for the prompt reply.

After placing the code in my functions.php file, I have tried everything – changing the position of the new line (before “Thank you” line, after the email subject line, etc.) – but it keeps sending the same email as before. I have also tried to make a small change within an original string, but with no result: the message sent is the same, as if placing the code in the function.php file has no effect whatsoever.

So now:
1. What can be wrong with what I’m doing?
2. Is there no way to create a new email message in the EE admin surface (that I can control) that override this hard coded message?

Thank you again for your kind help.


Tony

  • Support Staff

November 28, 2013 at 5:41 am

Hi,

I would advise you to use the Custom Files Add-on using the documentation available here:

https://eventespresso.com/wiki/custom-files-addon/

Then remove (Cut) the function you have created within the themes function.php file and add (Paste) it within the custom_functions.php file.

Pluggable functions within EE will not be overridden with functions within the themes functions.php file, they therefor need to be placed within the custom_functions.php file mentioned above.

Regarding question 2

Is there no way to create a new email message in the EE admin surface (that I can control) that override this hard coded message?

Unfortunately not with Event Espresso 3.X


B D

November 28, 2013 at 6:43 am

Thank you for the explanation.

I don’t have the Custom Files add-on, so probably the only solution for the time being is to modify the source code.

However, I’m wondering if it is possible to copy/replicate and tweak the email.php file in uploads which override the original email.php code, as I did with the .mo translation file?

Thank you again for your kind help.


Tony

  • Support Staff

November 28, 2013 at 7:01 am

In that case, you may want to create just a blank file named custom_functions.php in wp-content/uploads/espresso/

Place the function within there. The first line of the function you have modified is it

if (!function_exists('event_espresso_send_attendee_registration_approval_pending')) {

or

function event_espresso_send_attendee_registration_approval_pending($registration_id) {


B D

November 28, 2013 at 8:08 am

Thank you Tony. This is indeed the solution.

However, I run into an unexpected problem. My email message is in French and the French diacritic signs/accents are not rendered properly. Is there a solution for this?

Thanks again.


Tony

  • Support Staff

November 28, 2013 at 8:14 am

No problem.

How are the rendering currently? Can you post an example of the original and the output please.


B D

November 28, 2013 at 8:24 am

Thank you for the prompt reply.

Original string: “Nous vous remercions pour votre intérêt”
The output: “Nous vous remercions pour votre int?r?t”


Dean

November 29, 2013 at 2:18 am

Hi,

Is this a translated English string or is it just something you have added to the email?

This is from an email I sent myself http://d.pr/i/cUex, the first is a translated string and the second is the French added to the email. Both show the correct accent.

My thought is that the encoding is incorrect, though Event Espresso uses UTF8 which is correct.

Is this issue occurring anywhere else or is it just in the emails?


B D

November 29, 2013 at 2:33 am

Thank you for your reply.

This is not a translated string, but one string that I added in this email. My point in attempting to customize this email is to add strings that don’t exist in the EE original strings. This issue occurs only with this email, when adding the strings in the custom_functions.php file to customize the email.

I have sent the email with the French string to several addresses and the problem shows up in the email clients, both on the Internet (hotmail etc.) and local (Thunderbird). However, I currently work with the same email clients in French with no problem.

What would you advise?

Thank you again.


Dean

November 29, 2013 at 3:00 am

Hi,

Not sure yet. It is definitely an encoding issue, but I can’t see where the encoding would fail.

Can you send a copy of the email to support @ eventespresso . com ?


Tony

  • Support Staff

November 29, 2013 at 3:16 am

Have you modified the event_espresso_send_email() function at all? (email.php line 552+)

The email is sent using that function which has UTF-8 character set hardcoded. Just checking this has not been changed?


B D

November 29, 2013 at 4:04 am

Thank you for your reply.

No, I haven’t modified the event_espresso_send_email() function in the email.php. (I have not copied it in the custom_functions.php file either).(If needed, I send you this function’s code so that you can check.)

One point which may be useful: The strings that are translated in the .po/.mo files show the proper French accents/diacritics in the email. It is only the strings that I add directly to this email template in the custom_functions.php file that don’t show up properly.


Tony

  • Support Staff

November 29, 2013 at 4:28 am

Problem is I copied the string you posted to the same function (which I have placed in custom_functions.php to mirror your setup as much as I can) and had no problems with it, so its hard to find the cause.

If you would like to email your custom_functions.php file we’ll take a look, however I’m fairly sure it will be correct. (same email as above)

The other option is to add the phrase to the function in English, wrap it within __() and then translate it as you have the others and see if that works.

So the new line would be similar to

$body .= __('Thank you for the interest in our company', 'event_epsresso');

Then translate ‘Thank you for the interest in our company’ to ‘Nous vous remercions pour votre intérêt’.

Apologies if the above is incorrect, google translate.


B D

November 29, 2013 at 6:25 am

Thank you for your patience.

1. I paste hereafter the code I used in custom_functions.php

2. I had already thought about adding the phrases in English and translate them. However, I encounter the following problem: the French translation (the “official” .mo file I downloaded from your server) is not finished and various mistakes are to be corrected. To do so, I created my own .mo/.po files in the wp-content/uploads/espresso/languages file, so that my translations/correction will not be overwritten when updating.

Now, if I add English strings to my email, they will appear in the original .mo/.po file, thus they will not be visible and thus translatable in my customized .mo/.po files in the uploads file. How to import strings from the original .mo file to the modified .mo file? If I’m not mistaken, I cannot do this with Poedit.

And now the code:

<?php

if (!function_exists(‘event_espresso_send_attendee_registration_approval_pending’)) {

function event_espresso_send_attendee_registration_approval_pending($registration_id) {
global $org_options, $wpdb;
do_action(‘action_hook_espresso_log’, __FILE__, __FUNCTION__, ”);
//Get the event information
$events = $wpdb->get_results(“SELECT ed.* FROM ” . EVENTS_DETAIL_TABLE . ” ed
JOIN ” . EVENTS_ATTENDEE_TABLE . ” ea
ON ed.id = ea.event_id
WHERE ea.registration_id='” . $registration_id . “‘”);

foreach ($events as $event) {
$event_id = $event->id;
$event_name = stripslashes_deep($event->event_name);
$event_desc = stripslashes_deep($event->event_desc);
$display_desc = $event->display_desc;
$event_identifier = $event->event_identifier;
$reg_limit = $event->reg_limit;
$active = $event->is_active;
$send_mail = $event->send_mail;
$conf_mail = $event->conf_mail;
$email_id = $event->email_id;
$alt_email = $event->alt_email;
$start_date = event_date_display($event->start_date);
$end_date = $event->end_date;
$virtual_url = $event->virtual_url;
$virtual_phone = $event->virtual_phone;
$event_address = $event->address;
$event_address2 = $event->address2;
$event_city = $event->city;
$event_state = $event->state;
$event_zip = $event->zip;
$event_country = $event->country;
$location = ($event_address != ” ? $event_address : ”) . ($event_address2 != ” ? ‘<br />’ . $event_address2 : ”) . ($event_city != ” ? ‘<br />’ . $event_city : ”) . ($event_state != ” ? ‘, ‘ . $event_state : ”) . ($event_zip != ” ? ‘<br />’ . $event_zip : ”) . ($event_country != ” ? ‘<br />’ . $event_country : ”);
$location_phone = $event->phone;
$require_pre_approval = $event->require_pre_approval;

$google_map_link = espresso_google_map_link(array(‘address’ => $event_address, ‘city’ => $event_city, ‘state’ => $event_state, ‘zip’ => $event_zip, ‘country’ => $event_country));
}

//Build links
$event_url = espresso_reg_url($event_id);
$event_link = ‘< a href="' . $event_url . '">‘ . $event_name . ‘‘;

$sql = “SELECT * FROM ” . EVENTS_ATTENDEE_TABLE;

if ($registration_id != ”) {
$sql .= ” WHERE registration_id = ‘” . $registration_id . “‘ “;
} elseif ($attendee_id != ”) {
$sql .= ” WHERE id = ‘” . $attendee_id . “‘ “;
} else {
_e(‘No ID Supplied’, ‘event_espresso’);
}

$sql .= ” ORDER BY id “;
$sql .= ” LIMIT 0,1 “; //Get the first attendees details

$attendees = $wpdb->get_results($sql);
//global $attendee_id;

foreach ($attendees as $attendee) {
$attendee_id = $attendee->id;
$attendee_email = $attendee->email;
$lname = $attendee->lname;
$fname = $attendee->fname;
$address = $attendee->address;
$address2 = $attendee->address2;
$city = $attendee->city;
$state = $attendee->state;
$zip = $attendee->zip;
$payment_status = $attendee->payment_status;
$txn_type = $attendee->txn_type;
$amount_pd = $attendee->amount_pd;
$event_cost = $attendee->amount_pd;
$payment_date = event_date_display($attendee->payment_date);
$phone = $attendee->phone;
$event_time = event_date_display($attendee->event_time, get_option(‘time_format’));
$end_time = event_date_display($attendee->end_time, get_option(‘time_format’));
$date = event_date_display($attendee->date);
$pre_approve = $attendee->pre_approve;
}
$admin_email = $alt_email == ” ? $org_options[‘contact_email’] : $alt_email . ‘,’ . $org_options[‘contact_email’];
if (!empty($admin_email)) {
$subject = __(‘New attendee registration approval pending’,’event_espresso’);
$body = sprintf( __(‘Event title: %s’, ‘event_espresso’), $event_name );
$body .= ‘<br/>’;
$body .= sprintf( __(‘Attendee name: %1$s %2$s’, ‘event_espresso’), $fname, $lname );
$body .= ‘<br/>’;
$body .= __(‘Thank You.’, ‘event_espresso’);
$email_params = array(
‘send_to’ => $admin_email,
’email_subject’ => __($subject, ‘event_espresso’),
’email_body’ => $body
);
event_espresso_send_email($email_params);
}

if (!empty($attendee_email)) {
$subject = __(‘Event registration pending’,’event_espresso’);
$body .= ‘***Ceci est un message automatique. Veuillez ne pas y répondre***’;
$body = sprintf( __(‘Event title: %s’, ‘event_espresso’), $event_name );
$body .= ‘<br/>’;
$body .= sprintf( __(‘Attendee name: %1$s %2$s’, ‘event_espresso’), $fname, $lname );
$body .= ‘<br/>’;
$body .= __(‘Your registration is pending for approval from event admin. You will receive an email with payment info when admin approves your registration.’, ‘event_espresso’);
$body .= ‘<br/><br/>’;
$body .= ‘Nous vous remercions pour votre intérêt’;
$email_params = array(
‘send_to’ => $attendee_email,
’email_subject’ => __($subject, ‘event_espresso’),
’email_body’ => $body
);
event_espresso_send_email($email_params);
}
}

}


Tony

  • Support Staff

November 29, 2013 at 6:38 am

Could you try replacing that whole function with the one here please http://pastebin.com/iepAEgsh

Please do not make any changes to it currently, then try a new registration and check the email.

Or you can just replace the custom_functions.php file with this one http://d.pr/f/LnhV and test.


B D

November 29, 2013 at 6:52 am

Thank you.

The result is the same…

I’m wondering if exploring the second point in my above message (how to transfer strings from the original to the customized .mo/.po files) would not offer a simpler solution, insofar as translated strings show properly in French in email.


Josh

  • Support Staff

December 2, 2013 at 3:13 pm

Hi there,

Can you log into the WordPress admin and go to yoursite.com/wp-admin/options.php and look for the blog_charset option and let us know what the value is set for this option? This may help narrow down the issue.


B D

December 2, 2013 at 3:29 pm

Hi Josh,

I suppose you’re referring to the following lines:

if ( ! in_array( get_option( ‘blog_charset’ ), array( ‘utf8’, ‘utf-8’, ‘UTF8’, ‘UTF-8’ ) ) )
$whitelist_options[‘reading’][] = ‘blog_charset’;

The language of my WP is French.

B D


Josh

  • Support Staff

December 2, 2013 at 4:33 pm

I wasn’t referring to any particular line of code, but rather what’s set in the options table of your WordPress site, which you can find out by looking at the url I posted above (except you’ll swap in your domain for yoursite.com)


B D

December 3, 2013 at 1:49 am

The two lines above contain the only occurences of “blog_charset” in my options.php file.

Shall I send a copy of the whole options.php code here?


Dean

December 3, 2013 at 2:40 am

Hi,

It should look like this http://d.pr/i/JJHm

I created a site using a non English language install (Finnish) and it also by default had the blog_charset as a plain UTF-8

You may wish to backup your site and change that setting to UTF-8 to see if it resolves the issues you are having.


B D

December 3, 2013 at 2:48 am

Hi Dean

I can only see the options.php as a text file, so I cannot see the right side fields as in your screen copy. How should I open my options.php file so that I can see the value fields?


Tony

  • Support Staff

December 3, 2013 at 3:22 am

Hi,

If you go to yourdomain.com/wp-admin/options.php you’ll find all the options displayed.


B D

December 3, 2013 at 3:42 am

Sorry, I went to the options.php file through ftp.

I confirm that the value of blog_charset is UTF-8.

(My WP’s language is French).


Tony

  • Support Staff

December 3, 2013 at 3:55 am

Then that’s correct.

I think the next best thing is for one of us to take a look and see what we can find. Is is possible for you to send us log-in information?

If so please use https://eventespresso.com/send-login-details/

Note – Log-in details need to be admin level and FTP details are appreciated in this case.


Tony

  • Support Staff

December 5, 2013 at 3:03 am

Hi,

I just logged in and registered onto one of the pre-approval events and received this email with no problems with encoding.

I then added a couple of br tags to the function to separate out the lines a little and re-registered to test again.

This seems to working fine?

  • This reply was modified 10 years, 11 months ago by Tony. Reason: Removed email links


B D

December 5, 2013 at 4:31 am

Hi Tony,

Thank you for your work to begin with.

The message however remains very problematic. And this is a message that I need to use extensively, everyday.

I have just tested again and the first thing I note is the following: while the emails composed in French in the Email manager and the EE Settings arrive properly, with all the right French accents, the problem is this php automated email message.

Here are the results of my test with the pre-approval message:

I have sent the same message (as you sent) to three email addresses, one hotmail one gmail and one at my own server. I visualised the results a) on Thunderbird b) on three browsers (Firefox, Chrome, IE) on the email providers’ websites.

A) On Thunderbird, the three messages come with wrong encoding (the French accents are wrongly rendered, as black squares). I currently use Thunderbird to gather all my email and I work extensively with French without any problem. My Thunderbird’s encoding is UTF 8 and its language is French.

B) On the hotmail site, the message come with wrong encoding too, irrespective of the browser. (On the other hand, messages sent to hotmail with the EE Email Manager are fine in French).

C) On the gmail site, the message is rendered fine, with the proper accents. However, the same message is rendered wrongly when read in Thunderbird.

D) On my server, the message shows up correctly when read in the browser, and wrong in Thunderbird.

So in sum while the messages sent from the Email manager are fine, this particular php encoded message is still problematic on hotmail and in email clients like Thunderbird (and presumably Outlook).

What would you suggest?

(May I ask you, for confidentiality reasons, to remove the links to my email message from your above message?).

Thank you again.

B D


Tony

  • Support Staff

December 5, 2013 at 4:58 am

Apologies, the links and files have been removed.

I’ll log back in now and run a couple more registrations.


Tony

  • Support Staff

December 5, 2013 at 6:18 am

Managed to get this working, I was trying to avoid manually adding files to the PO files as it can get rather messy, but seems this is the only way for this to work (which is very odd as it should be the same)

Regardless, you’ll need to manually add your translations to the .PO file. I did this with Sublime, but any Plain Text Source Editor (for example notepad++) will do as long as it does NOT add its own meta data to the file (such as MS Word)

If you open download event_espresso-fr_FR.po from uploads/espresso/languages and open the file within a text editor, go to the end of the file, you’ll find.

# @ event_espresso
#: ../../uploads/espresso/custom_functions.php:110
msgid "Thank you for your interest"
msgstr "Nous vous remercions pour votre intérêt"

First line is the text domain used ‘event_espresso’
Second line is the file and line number the original text is on.
Third line the original text to translate.
Forth is the translated text.

You’ll need to repate that section replacing the line number, orig and translated text for each line you want to translate.

Looking in the custom_functions.php file line 110. You’ll find:

$body .= __('Thank you for your interest.', 'event_espresso');

You’ll need to wrap any other phrases you want to translate in a similar fashion, so looking on line 102, it needs to be wrapped with __() and given the text domian ‘event_espresso’.

Remember as you add new phrases/move them around, the line numbers for the ones below may change, these need to then be modified in the PO file.

Once you’ve added all your phrases/translations to custom_functions.php and the PO file, save and close the editor. Open the PO file in POEdit and click save. It will generate a .MO file. Copy/replace both the files to uploads/espresso/languages.

If you have any questions just let me know.


B D

December 5, 2013 at 8:26 am

Thank you very much for this clear explanation and for your help.

I have tested and encounter the following problems:

1. I have placed a text line (as $body = __(‘my text’, ‘event_espresso’);) in the email’s body before the event’s name (that’s where I need it), that is, before the php line $body = sprintf( __(‘Event title: %s’, ‘event_espresso’), $event_name ). Although it figures correctly in the .po file and I can see it translated in Poedit, this line does not show at all in the email message.

2. For some reason, the last line of the message only shows up in English in the email message, although it is correctly translated in French and the custom_functions.php line is properly indicated in the .po file.

Thank you again for your kind help.


Tony

  • Support Staff

December 5, 2013 at 8:46 am

1) The first line of the email message needs be set using = then and extra lines .= so line 100:

$body = __('<strong>***This is an automated response - Do Not Reply***</strong>', 'event_espresso');

line 102

$body .= sprintf( __('Event title: %s', 'event_espresso'), $event_name );

2) A full stop (.) has been added to that line but not within the PO file. The strings to translate must match exactly.

Also the translation you have added to the PO is incorrectly formatted, follow the one I added and ensure the formatting is correct. I would advise you remove the strong tags from the PO and place them around the string within custom_functions.


B D

December 5, 2013 at 9:55 am

Thank you. The second point is solved.

And my last question: you advise to remove the strong tags from the .po and place them around the string within custom_functions. Where should I place exactly the strong tags outside the string (which is the first line of the email message)?


Josh

  • Support Staff

December 6, 2013 at 8:53 am

You could also simply remove them:

$body = __('***This is an automated response - Do Not Reply***', 'event_espresso');


B D

December 6, 2013 at 8:59 am

Thank you Josh. That’s what I did for the time being.

However, I need this string emphasized in the email message. But not being a php coder, I’m wondering where to place the tags around this string.


Tony

  • Support Staff

December 6, 2013 at 9:16 am

I tested:

$body = '<strong>' . __('***This is an automated response - Do Not Reply***', 'event_espresso') . '<strong>'; 

Which worked fine 🙂


B D

December 6, 2013 at 9:45 am

Thank you so much Tony for your patient help and clear explanations along this long thread. It’s working fine now.

If EE is to become a global success, translation issues (and multilingual sites issues) will need to be addressed so that to make life easier to non-coders…

Thank you again.

B D


Tony

  • Support Staff

December 6, 2013 at 10:13 am

Thank you for the feedback 🙂

We are focusing heavily on EE4 which will (eventually) be much more flexible in a lot of areas including translations.

I’m glad this is now all working anyway 🙂


Bryan Luff

December 20, 2013 at 2:41 pm

I am needing to edit the same email that my attendees are receiving. We are holding an invitation only, free event. The attendee comes to our sight to register, which is really an RSVP. I am EXTREMELY hesitant to edit the php as it’s a live site and I only know enough to destroy the work I’ve already done. I really need to soften the language of the automatic email that is sent. I am using the pre-approval function so that our admin can approve each attendee to her master list. Is there a work around where we can automatically send a follow up email that clarifies that no payment is necessary, or can you guys go in and edit the php for me?

Thanks!


Tony

  • Support Staff

December 27, 2013 at 2:25 am

Hi Bryan,

I am sorry for the delayed reply, once a thread is marked resolved (like this one) we no longer receive updates for that thread so I would recommend starting a new thread for any/all issues you may have and reference other threads within there if need be, just to be sure your questions is not missed 🙂

Regarding your question, really it depends on how much you would like to add to the email.

All of the strings within the email are translatable, meaning you can translate them to become any string you want. You can do this using the plugin or function included within the documentation available here.

https://eventespresso.com/wiki/how-to-change-wording-with-poedit/#plugins

Now you mention you would rather not alter the code, in which case I would recommend using the plugin posted as they both do the same thing.

If you look in event-espresso/includes/functions/email.php lines 849-856 you can see how the email is constructed. So say you want to translate ‘Your registration is pending for approval from event admin. You will receive an email with payment info when admin approves your registration.’ using the plugin.

Put that full string exactly as is into the ‘old’ text field. Your replacement for that string in the ‘new’ text field, and the text-domain would be event_espresso.

Does that help?

Viewing 39 reply threads

The support post ‘Modifyng the pre-approval confirmation email’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso