-
AuthorPosts
-
October 6, 2015 at 5:45 pm #514638
Hello,
I added following lines to child theme functions.php in order to have greetings (Dear) and submitted user name and surname at the beginning of autorespoder message:
function modify_autorespondermessage_func($message) {
$new_message = “Dear “. $_POST[‘avia_name_1’].” “. $_POST[‘avia_surname_1’].”,<br><br>”;
$new_message .= $message;return $new_message;
}
add_filter(‘avf_form_autorespondermessage’, ‘modify_autorespondermessage_func’, 10, 1);This solution worked perfectly until I installed Polylang in order to duplicate all my pages and translate them to another language – German.
Now, autoresponder from English pages works fine, but at the beginning of messages sent from German pages I also have Dear (which I would like to change to German – Hallo, if sent from German page) and missing name and surname because this fields in Germans are not Name and Surname but Vorname and Nachname.
Last time with above code Josue solved problem. Is there any solution for this?
Regards,
Ivan
October 7, 2015 at 10:00 am #515058Hi Ivan!
You’d need to put a condition, something like:
function modify_autorespondermessage_func($message) { if( pll_current_language('locale') == 'de_DE' ){ $salute = "Hallo"; }else{ $salute = "Dear"; } $new_message = $salute.$_POST[‘avia_name_1′].” “. $_POST[‘avia_surname_1′].”,<br><br>”; $new_message .= $message; return $new_message; } add_filter(‘avf_form_autorespondermessage’, ‘modify_autorespondermessage_func’, 10, 1);
Reference:
https://polylang.wordpress.com/documentation/documentation-for-developers/functions-reference/Best regards,
JosueOctober 7, 2015 at 12:59 pm #515137Hi Josue,
Thanks for reply. This code returns error page
Parse error: syntax error, unexpected ‘“’ (T_STRING) on line 15
Line 15 is $new_message = $salute.$_POST[‘avia_name_1′].” “. $_POST[‘avia_surname_1′].”,<br><br>”;
On the other hand it seams that this code affect just greetings: Hallo/ Dear… , but not name and surname fields which are Vorname and Nachname in German.
Sorry, I really don’t know much about programming so I couldn’t fix this by my self.
Cheers,
IvanOctober 7, 2015 at 1:04 pm #515143Hey!
Please go to wp-content/themes/enfold and remove the code from functions.php file via FTP and then create a temporary admin login and post it here privately so we can add it for you.
Regards,
YigitOctober 7, 2015 at 1:15 pm #515161Hello,
Credentials are in private content section. There is also username and password for protected admin folder.
Regards,
Ivan
October 7, 2015 at 1:17 pm #515165October 7, 2015 at 1:28 pm #515185good one!
October 7, 2015 at 1:38 pm #515193Hey!
I have added Josue’s code to functions.php file of your child theme successfully. Please review your website now.
Best regards,
YigitOctober 7, 2015 at 1:46 pm #515200Hey Yigit,
It’s fine now as for greetings message (Hallo/ Dear), but since name and last name fields are different in German, there is no name and last name after Hallo, when message is sent from German page. Probably because autoresponder pick up this from fields avia_name_1 and avia_surname_1, and not from avia_vorname_1 and avia_nachname_1 – which are those fields in German form.
Any ideas on this?
Thank you for this.
October 7, 2015 at 2:12 pm #515225Hi,
Can you please create us a temporary FTP / SFTP account? post it here as a private reply.
Regards,
JosueOctober 7, 2015 at 2:18 pm #515233Hi,
Here it is. Hope I didn’t miss something.
Regards,
IvanOctober 7, 2015 at 2:28 pm #515244Ok, try your form now, i’ve changed the code to this:
function modify_autorespondermessage_func($message) { if( pll_current_language('locale') == 'de_DE' ){ $salute = "Hallo"; $firstname = $_POST['avia_name_1']; $lastname = $_POST['avia_surname_1']; }else{ $salute = "Dear"; $firstname = $_POST['avia_vorname_1']; $lastname = $_POST['avia_nachname_1']; } $new_message = $salute." ".$firstname." ".$lastname."<br><br>"; $new_message .= $message; return $new_message; } add_filter('avf_form_autorespondermessage', 'modify_autorespondermessage_func', 10, 1);
Cheers!
JosueOctober 7, 2015 at 2:38 pm #515249Hi,
Well, … Hallo and Dear is OK now it changes according to language. But there is neither first nor last name (both in English and in German language), neither comma after last name.
Ivan
October 7, 2015 at 3:07 pm #515281Can you post a link to the forms? both English and German versions.
October 7, 2015 at 3:34 pm #515305Sure Josue! There is a several forms, but here is an one example:
October 7, 2015 at 10:40 pm #515479Hey!
Try it now, here’s the final code:
function modify_autorespondermessage_func($message) { if( pll_current_language('locale') == 'de_DE' ){ $salute = "Hallo"; $firstname = 'avia_vorname_1'; $lastname = 'avia_nachname_1'; }else{ $salute = "Dear"; $firstname = 'avia_name_1'; $lastname = 'avia_surname_1'; } $new_message = $salute." ".$_POST[$firstname]." ".$_POST[$lastname]."<br><br>"; $new_message .= $message; return $new_message; } add_filter('avf_form_autorespondermessage', 'modify_autorespondermessage_func', 10, 1);
Cheers!
JosueOctober 7, 2015 at 11:38 pm #515504Dear Josue and Kriesi support,
You are amazing!
I just added comma after greetings and now everything works as it should.
Thank you so much!
October 7, 2015 at 11:50 pm #515510You are welcome, glad to help :)
Regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.