• Resolved webwerkplaats

    (@webwerkplaats)


    I have used your contact-form-email plugin to expand the content of the form and subsequent email to the admin.
    I would like to add an extra field ( “telefoon” ) to the form AND it should be included in the mail that is sent.

    // 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”;
    $mail[“message”] .= “Email: ” . $form->get_value( “message_email” ) . “\r\n”;
    $mail[“message”] .= “Telefoon: ” . $form->get_value( “message_telefoon” ) . “\r\n”;

    // Allways make sure to return $mail
    return $mail;
    }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter webwerkplaats

    (@webwerkplaats)

    Can you help me add the “Telelfoon” field to the form and the mail it send ?
    Preferrably added to the contact-form-email plugin ?

    Plugin Author Greg Winiarski

    (@gwin)

    Add in your theme functions.php file the code below

    
    add_filter( "adverts_form_load", "contact_form_bind" );
    function contact_form_bind( $form ) {
      if( $form['name'] != "contact" ) {
        return $form;
      }
      $form["field"][] = array(
        "name" => "message_telefoon",
        "type" => "adverts_field_text",
        "order" => 50,
        "label" => __( "Telelfoon", "adverts"),
        "validator" => array(
          array(
            "name" => "string_length",
            "params" => array( "min" => 5 )
          )
        )
      );
      return $form;
    }
    

    Now when user will send a contact form and will fill the new phone field, then the phone number should be visible in the contact email assuming you have the code from your first message added as well.

    Thread Starter webwerkplaats

    (@webwerkplaats)

    Works like a charm ! Thanks for (again) the rapid an right answers !
    Thanks Greg!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Add telephone number to reaction for AND email’ is closed to new replies.