I’m using code from another source but it’s very different to what I’m used to coding when using standard HTML/PHP websites. WordPress seems to have a mind of it’s own. Basically I need the contact form’s PHP to send the name and email within the body text of the email and not just the persons message. Currently all that comes through is the persons message.

  //response generation function
  $response = "";
  //function to generate response
  function my_contact_form_generate_response($type, $message){
    global $response;
    if($type == "success") $response = "<div class='success'>{$message}</div>";
    else $response = "<div class='error'>{$message}</div>";
  //response messages
  $not_human       = "Human verification incorrect.";
  $missing_content = "Please Fill in all Required Fields.";
  $email_invalid   = "Your Email Address is Invalid.";
  $message_unsent  = "Message was not sent. Please Try Again.";
  $message_sent    = "Thanks! Your message has been sent.";
  //user posted variables
  $name = $_POST['message_name'];
  $email = $_POST['message_email'];
  $message = $_POST['message_text'];
  $human = $_POST['message_human'];
  //php mailer variables
  $to = get_option('admin_email');
  $subject = "New Enquiry Through Mon Voyage Website";
  $headers = 'From: '. $email . "rn" .
    'Reply-To: ' . $email . "rn";
  if(!$human == 0){
    if($human != 2) my_contact_form_generate_response("error", $not_human); //not human!
    else {
      //validate email
      if(!filter_var($email, FILTER_VALIDATE_EMAIL))
        my_contact_form_generate_response("error", $email_invalid);
      else //email is valid
        //validate presence of name and message
        if(empty($name) || empty($message)){
          my_contact_form_generate_response("error", $missing_content);
        else //ready to go!
          $sent = wp_mail($to, $subject, strip_tags($message), $headers);
          if($sent) my_contact_form_generate_response("success", $message_sent); //message sent!
          else my_contact_form_generate_response("error", $message_unsent); //message wasn't sent
  else if ($_POST['submitted']) my_contact_form_generate_response("error", $missing_content);

Any ideas?

Read more here: WordPress Custom PHP contact form


If you know the solution of this issue, please leave us a reply in Comment section, to update the question.

Related Wordpress search:

, , , ,

Wordpress related questions and answers: