Viewing 18 posts - 1 through 18 (of 18 total)
  • Author
    Posts
  • #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

    #515058

    Hi 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,
    Josue

    #515137

    Hi 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,
    Ivan

    #515143

    Hey!

    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,
    Yigit

    #515161

    Hello,

    Credentials are in private content section. There is also username and password for protected admin folder.

    Regards,

    Ivan

    #515165

    Hey!

    Can you please post the link to your website as well? :)

    Regards,
    Yigit

    #515185

    good one!

    #515193

    Hey!

    I have added Josue’s code to functions.php file of your child theme successfully. Please review your website now.

    Best regards,
    Yigit

    #515200

    Hey 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.

    #515225

    Hi,

    Can you please create us a temporary FTP / SFTP account? post it here as a private reply.

    Regards,
    Josue

    #515233

    Hi,

    Here it is. Hope I didn’t miss something.

    Regards,
    Ivan

    #515244

    Ok, 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!
    Josue

    #515249

    Hi,

    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

    #515281

    Can you post a link to the forms? both English and German versions.

    #515305

    Sure Josue! There is a several forms, but here is an one example:

    #515479

    Hey!

    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!
    Josue

    #515504

    Dear Josue and Kriesi support,

    You are amazing!

    I just added comma after greetings and now everything works as it should.

    Thank you so much!

    #515510

    You are welcome, glad to help :)

    Regards,
    Josue

Viewing 18 posts - 1 through 18 (of 18 total)
  • You must be logged in to reply to this topic.