Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何将wp_邮件更改为订阅者电子邮件id_Php_Wordpress_Email - Fatal编程技术网

Php 如何将wp_邮件更改为订阅者电子邮件id

Php 如何将wp_邮件更改为订阅者电子邮件id,php,wordpress,email,Php,Wordpress,Email,我正试图在wordpress上设置一个带有插件的登录页-很快就会出现。它有一个订阅框。每次有人订阅时事通讯,我都会收到一封电子邮件wordpress@mydomain.com带着通知。如何更改它,使我从订阅者的邮件id本身而不是从订阅者的邮件id本身获取邮件wordpress@mydomian.com.In换句话说,它从订阅者的电子邮件id获取并发送邮件,而不是wp_邮件。 这是我在插件文件中找到的- /** * [ajax_newsletter_subscribe description]

我正试图在wordpress上设置一个带有插件的登录页-很快就会出现。它有一个订阅框。每次有人订阅时事通讯,我都会收到一封电子邮件wordpress@mydomain.com带着通知。如何更改它,使我从订阅者的邮件id本身而不是从订阅者的邮件id本身获取邮件wordpress@mydomian.com.In换句话说,它从订阅者的电子邮件id获取并发送邮件,而不是wp_邮件。 这是我在插件文件中找到的-

/**
 * [ajax_newsletter_subscribe description]
 * @return [type] [description]
 */
public function ajax_newsletter_subscribe() {

    check_ajax_referer( 'cc-cs-newsletter-subscribe' );

    $to_email = $this->get_option('newsletter', 'email') ? $this->get_option('newsletter', 'email') : get_option( 'admin_email' );

    if(filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {

        $sent = wp_mail(
            $to_email,
            __('You have a new subscriber!', $this->plugin_slug),
            sprintf(__("Hello,\n\nA new user has subscribed through your Coming Soon page.\n\nSubscriber's email: %s", $this->plugin_slug), $_POST['email'])
        );

        if($sent) {
            print json_encode(array('status' => 'ok'));
            die();
        }
    }

    print json_encode(array('status' => 'error'));
    die();
}

您可以设置电子邮件
$headers
,其中
来自

$headers = array();
$headers[] = 'From: ' . $_POST['email'] . ' <' . $_POST['email'] . '>';

$sent = wp_mail(
    $to_email,
    __( 'You have a new subscriber!', $this->plugin_slug ),
    sprintf( __( "Hello,\n\nA new user has subscribed through your Coming Soon page.\n\nSubscriber's email: %s", $this->plugin_slug ), $_POST['email'] ),
    $headers
);
$headers=array();
$headers[]='发件人:'$_发布['email'].';
$sent=wp\u邮件(
$to_电子邮件,
__(“您有一个新订户!”,$this->plugin\u slug),
sprintf(\uuuuu(“您好,\n\n新用户已通过您即将到来的页面订阅了。\n\n订阅者的电子邮件:%s“,$this->plugin\u slug),$\u POST['email']),
$headers
);

查看。

嘿,迪吉,谢谢你的回复。对不起,我对编码有点陌生,你能告诉我我应该在“发件人”中放置什么,这样它就可以获取订阅者的电子邮件id吗?