PhP Contact form in Wordpress

扶醉桌前 提交于 2019-12-31 06:01:09

问题


So I bought a theme that has a simple PHP contact form that allows users to message each other, but when a sender fills out the form and submits it, the email comes from my default Wordpress Admin email and not the email address the user inputs in the form. So if the receiver tries to reply to their email, it's going to come to me (Admin) and not the person who sent the email.

Am I missing something here...seems pretty straight forward. I've tried changing it up and using $headers, etc., but nothing works... always just comes from my admin email.

Here is the form code:

<form method="post"><input type="hidden" value="<?php the_ID(); ?>" name="pid_rep" />
     <li>
        <h3><?php echo __('Your Email'); ?>:</h3>
    <p><input type="text" size="50" class="do_input"  name="email" /></p>
    </li>
    <li>
        <h3><?php echo __('Message'); ?>:</h3>
    <p><textarea rows="4" cols="40" class="do_input" name="message"></textarea>
    <<input type="submit" name="contact" value="<?php _e('Send Message'); ?>" /></p>
    </li>
</form>

Here is the handler:

    $email = $_POST['email'];
    $message = nl2br($_POST['message']);

回答1:


As I know it is a WordPress security setting and you can't change it. The email sender's domain name must be equal with your website domain name. Possible to define a custom, even not existing sender email address and sender name, you can do it with this plugin: WordPress Contact Form Slider



来源:https://stackoverflow.com/questions/23590485/php-contact-form-in-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!