• Resolved gutembergz

    (@gutembergz)


    Hi, Greg

    I’m using the contact form addon and I’d like to customize the message that is sent from plugin – I’m using the snippet contact-form-email too.

    Creating a new field called “phone”, now this field is showed at the first line; before, the message was beginning at the first line.

    How could I show the message at the end, plus this new field, after the following piece of code?

    (...)
    
    // Include Advert price and location at the end of message
        $mail["message"] .= "\r\n---\r\n";
        $mail["message"] .= adverts_price( get_post_meta( $post_id, "adverts_price", true ) ) . "\r\n";
        $mail["message"] .= get_post_meta( $post_id, "adverts_location", true ) . "\r\n";
    (...)    
    • This topic was modified 8 years, 10 months ago by gutembergz.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    Hi, if i understand correctly in the email body you would like to have first the price, location and phone then the message text? If so then the code below should do it

    
    $message = $mail["message"];
    
    $mail["message"]  = "";
    $mail["message"] .= adverts_price( get_post_meta( $post_id, "adverts_price", true ) ) . "\r\n";
    $mail["message"] .= get_post_meta( $post_id, "adverts_location", true ) . "\r\n";
    $mail["message"] .= get_post_meta( $post_id, "your_custom_field_name_here", true ) . "\r\n";
    $mail["message"] .= "\r\n---\r\n";
    $mail["message"] .= $message;
    
    Thread Starter gutembergz

    (@gutembergz)

    Yes, right! Now the lines are in the order that I need, thank you so much.

    Now… I’d like to insert a new field that I’ve created at the custom fields addon inside the contact message — a field called “telephone”:

    $mail["message"] .= get_post_meta( $post_id, "telephone", true ) . "\r\n";

    I think that field is being fetched from the ad post; I need from the form.

    Yes, the extra field “telephone” appears already, but at the first line…

    PS: Can you inform the code line to fetch the fields “reply_to” and “name” from the form?

    I appreciate your help and kindness.

    Plugin Author Greg Winiarski

    (@gwin)

    The mail headers including reply_to you can set like this

    
    $mail["headers"][] = "Reply-To: " . get_post_meta( $post_id, "adverts_email", true );
    

    as explained here https://github.com/simpliko/wpadverts-snippets/blob/master/contact-form-email/contact-form-email.php

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Contact Form Add On’ is closed to new replies.