首页 文章

Wordpress联系表格主题问题

提问于
浏览
0

我在上一个网站遇到的问题之一是联系表格 - 它使用静态主题方法..这很好 - 但问题是如果你使用Gmail,那么它会将同一主题的电子邮件分组,而不是理想的,特别是如果你期望大量的流量 .

在我使用的主题上有一个主题字段,但似乎根本没有使用它 . 当我发送测试信息时,我收到了:

电子邮件主题:.am - 联系表单中的消息

网站:.am

姓名:亚历克斯

电子邮件:test@test.tld

主题:.am - 来自联系表单的消息

消息:测试体 .

因此,我在主题字段中输入的任何文本都被完全忽略,然后从电子邮件主题中提取静态文本,并再次在正文中重复 .

我已将代码放在相应的页面中(我想?) .

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;
}

基本上,我想要的是

电子邮件主题:$ site | $主题 - 用户输入

名称:

电子邮件:

信息:

我该如何修改代码来做到这一点?因为这:

$subject = $site . __(' - message from contact form', TPL_SLUG);
. __('Subject: ', TPL_SLUG) . $subject . "\n\n"

似乎有点无意义 .

编辑

如果有任何帮助,我已经找到了表单本身的代码:

<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>

1 回答

  • 0

    我真的可以't say for certain as I don'知道 $subject 在哪里得到它的原始值,我也不知道你的html表格是什么样的 .

    $subject = $site . __(' - message from contact form', TPL_SLUG);

    可能会改为

    $subject = $site . ' | ' . $subject;

    $body 将如下所示:

    $body = __('Site: ', TPL_SLUG) . $site . "\n\n"
    . __('Name: ', TPL_SLUG) . $name . "\n\n"
    . __('Email: ', TPL_SLUG) . $email . "\n\n"
    . __('Message: ', TPL_SLUG) . $content;
    

相关问题