Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

chiaroscuro1 on "Need to tweak code for contact form"

$
0
0

I need someone to help me with a minor tweak to some contact form code.

I added two custom fields in a contact form a " Phone field" and a "Title, Company" field. They both look great.

I found some code that allows the phone number entered in the contact form field to appear in the email body. It works great. I tried to tweak that code so that the info in the "Title, Company" field also appears in the email body. However, although the field title is showing up, the info that is entered in the field doesn't.

PLEASE DO NOT recommend Contact Form 7. I have tried that plug-in and it does not look good with the theme, and it inserts the contact form in the wrong place and is more of a hassle than figuring out how to fix this minor probleem. It seems like a minor tweak to the code (see below) is all that I needs. Thanks for any help, in advance. My url is http://www.catalysthealthmedia.com, you can see the contact form there.

Currently, this is what appears in the email body:

Phone No: 973-761-1980
Title,Company:
Are you available for a project?

This is the mail code:

wp_mail( apply_filters( 'et_contact_page_email_to', $et_email_to ), sprintf( '[%s] ' . sanitize_text_field( $_POST['et_contact_subject'] ), $et_site_name ), esc_html('Phone No: ' . $_POST['et_contact_phone'] . "\r\n" . 'Title,Company: ' . $_POST['et_contact_Title, Company'] . "\r\n" . $_POST['et_contact_message'] ),apply_filters( 'et_contact_page_headers', $headers, $contact_name, $contact_email ) );

This is the code for the fields:

p class="clearfix">
<label for="et_contact_Title, Company" class="et_contact_form_label"><?php esc_html_e('Title, Company','SimplePress'); ?></label>
<input type="text" name="et_contact_Title, Company" value="<?php if ( isset($_POST['et_contact_Title, Company']) ) echo esc_attr($_POST['et_contact_Title, Company']); else esc_attr_e('Title, Company','SimplePress'); ?>" id="et_contact_Title, Company" class="input" />
</p>

<p class="clearfix">
<label for="et_contact_email" class="et_contact_form_label"><?php esc_html_e('Email Address','Foxy'); ?></label>
<input type="text" name="et_contact_email" value="<?php if ( isset($_POST['et_contact_email']) ) echo esc_attr($_POST['et_contact_email']); else esc_attr_e('Email Address','Foxy'); ?>" id="et_contact_email" class="input" />
</p>

<p class="clearfix">
<label for="et_contact_phone" class="et_contact_form_label"><?php esc_html_e('Phone','SimplePress'); ?></label>
<input type="text" name="et_contact_phone" value="<?php if ( isset($_POST['et_contact_phone']) ) echo esc_attr($_POST['et_contact_phone']); else esc_attr_e('Phone','SimplePress'); ?>" id="et_contact_phone" class="input" />
</p>


[Please use the code buttons when posting code here]

Viewing all articles
Browse latest Browse all 8245

Trending Articles