One of the problems I was experiencing with my last site was the Contact Form - it uses a static subject approach.. which is fine - but the problem is if you use Gmail, then it will group emails of the same subject which isn't ideal, especially if you expect a lot of traffic that way.
On the theme I'm using there's a Subject field, but it doesn't seem to be utilized at all. When I sent my test message, I received:
EMAIL SUBJECT: .am - message from contact form
Site: .am
Name: Alex
Email: [email protected]
Subject: .am - message from contact form
Message: Test body.
So whatever text I entered into the subject field was completely ignored, and then static text was pulled from the e-mail subject and repeated, again, in the body.
I've located the code in the respective page (I think?).
APOLLO13.PHP
if (empty($name))
$name_error = true;
if (empty($email) || !is_email($email))
$email_error = true;
if (empty($subject))
$subject_error = true;
if (empty($content))
$content_error = true;
if ($name_error == false && $email_error == false && $content_error == false && $subject_error == false) {
$subject = $site . __(' - message from contact form', TPL_SLUG);
$body = __('Site: ', TPL_SLUG) . $site . "\n\n"
. __('Name: ', TPL_SLUG) . $name . "\n\n"
. __('Email: ', TPL_SLUG) . $email . "\n\n"
. __('Subject: ', TPL_SLUG) . $subject . "\n\n"
. __('Message: ', TPL_SLUG) . $content;
$headers = "From: $name <$email>\r\n";
$headers .= "Reply-To: $email\r\n";
if (wp_mail($email_to, $subject, $body, $headers)) {
$title_msg = __('Success sending form', TPL_SLUG);
} else
$title_msg = __('Something wrong. Try again!', TPL_SLUG);
} else {
$title_msg = __('Error in form', TPL_SLUG);
if (!empty($name))
$name_tag = 'value="' . $name . '"';
if (!empty($email))
$email_tag = 'value="' . $email . '"';
if (!empty($subject))
$phone_tag = 'value="' . $subject . '" title="' . __('General question ...', TPL_SLUG) . '"';
if (!empty($content))
$content_tag = $content;
}
And what I want is, essentially
EMAIL SUBJECT: $site | $subject-user-entered
Name:
Email:
Message:
How would I go about amending the code to do that? Because this:
$subject = $site . __(' - message from contact form', TPL_SLUG);
. __('Subject: ', TPL_SLUG) . $subject . "\n\n"
Seems a little pointless.
EDIT
I've found the code for the form itself if that's of any help:
<form action="http<?php echo $ssss ?>://<?php echo $_SERVER["SERVER_NAME"] . $_SERVER["REQUEST_URI"] ?>"
method="post" id="contact-form-<?php echo $form_iter ?>" class="contact-form styled-form">
<div class="submit_inputs">
<div<?php echo ($name_error ? ' class="error"' : '') ?>>
<input id="apollo13-contact-name" name="apollo13-contact-name" type="text" value=""/>
<label for="apollo13-contact-name">
<?php echo __('Name', TPL_SLUG) ?>
<span> (<?php echo __('required', TPL_SLUG) ?>)</span>
</label>
</div>
<div style="clear: both;"></div>
<div<?php echo ($name_error ? ' class="error"' : '') ?>>
<input id="apollo13-contact-email" name="apollo13-contact-email" type="text" value="" class="email"/>
<label for="apollo13-contact-email">
<?php echo __('Email', TPL_SLUG) ?>
<span> (<?php echo __('required', TPL_SLUG) ?>)</span>
</label>
</div>
<div style="clear: both;"></div>
<div<?php echo ($name_error ? ' class="error"' : '') ?>>
<input class="placeholder" id="apollo13-contact-subject" name="apollo13-contact-subject" type="text"
value=""/>
<label for="apollo13-contact-subject">
<?php echo __('Subject', TPL_SLUG) ?>
</label>
</div>
</div>
<div style="clear: both;"></div>
<div<?php echo ($name_error ? ' class="error"' : '') ?>>
<textarea id="apollo13-contact-content" name="apollo13-contact-content" rows="10" cols="40"></textarea>
</div>
<div>
<input type="hidden" name="apollo13-contact-form" value="send"/>
<input id="contact-submit" type="submit" value="<?php echo __('Submit form', TPL_SLUG) ?>"/>
</div>
</form>