Php WordPress,在发送邮件钩子到FeedBurner之前,通过wpcf7从联系人表单7传递已发布的数据

Php WordPress,在发送邮件钩子到FeedBurner之前,通过wpcf7从联系人表单7传递已发布的数据,php,wordpress,hook,contact-form-7,feedburner,Php,Wordpress,Hook,Contact Form 7,Feedburner,我正在开发一个WordPress插件,它使用联系人表单7 wpcf7_before_send_mail操作钩子抓取在CF7中输入的电子邮件,如果用户选中复选框,则将电子邮件传递给MailChimp和FeedBurner MailChimp部分正在工作,因为我能够使用API来传递订阅。然而,根据我的研究,订阅FeedBurner的唯一方法似乎是使用他们的表单,这对于我几个月前开发的这个插件的简单版本来说效果很好,但是似乎每当我在发送邮件之前通过wpcf7_呼出任何东西(比如隐藏表单)时,它就会杀死

我正在开发一个WordPress插件,它使用联系人表单7 wpcf7_before_send_mail操作钩子抓取在CF7中输入的电子邮件,如果用户选中复选框,则将电子邮件传递给MailChimp和FeedBurner

MailChimp部分正在工作,因为我能够使用API来传递订阅。然而,根据我的研究,订阅FeedBurner的唯一方法似乎是使用他们的表单,这对于我几个月前开发的这个插件的简单版本来说效果很好,但是似乎每当我在发送邮件之前通过wpcf7_呼出任何东西(比如隐藏表单)时,它就会杀死CF7。以下是我的代码的相关部分:

add_action( 'wpcf7_before_send_mail', 'before_send_mail' );
function before_send_mail($wpcf7) {
    if (is_array($wpcf7->posted_data["subscribe"])){
    $subscribe_news = in_array ('Newsletter',$wpcf7->posted_data["subscribe"]);
    $subscribe_blog = in_array ('Blog',$wpcf7->posted_data["subscribe"]);
    }
    $subscribe_email = $wpcf7->posted_data["your-email"];  
    $subscribe_email = $wpcf7->posted_data["your-email"];       
    if($subscribe_news){ ktmcf7_submit_mailchimp($subscribe_email); }
    if($subscribe_blog){ ktmcf7_submit_feedburner($subscribe_email); }    
    }
function ktmcf7_submit_feedburner($subscribe_email){
    $options = get_option( 'ktm_singlesub_options' );
    ?>
    <script>
        alert('feedburner');
        window.open('http://feedburner.google.com/fb/a/mailverify?uri=<?php echo $options['feedburner_id'] ?>', 'popup5', 'scrollbars=yes,width=550,height=520');
    </script>
    <form name="form2" action="http://feedburner.google.com/fb/a/mailverify" method="post" target="popup5" >
        <input type="hidden" name="email" value="<?php echo $subscribe_email ?>" />
        <input type="hidden" value="<?php echo $options['feedburner_id'] ?>" name="uri"/>
        <input type="hidden" name="loc" value="en_US"/>
        <!-- input type="submit" value="Subscribe2" style="visibility:hidden;height:5px;" / -->
    </form>
    <script>
        document.form2.submit();
    </script>
add_action('wpcf7_-before_-send_-mail','before_-send_-mail');
发送邮件前的功能($wpcf7){
如果(是_数组($wpcf7->发布的_数据[“订阅”])){
$subscribe_news=在_数组中('Newsletter',$wpcf7->发布的_数据[“subscribe”]);
$subscribe_blog=在_数组中('blog',$wpcf7->发布的_数据[“subscribe”]);
}
$subscribe_email=$wpcf7->posted_数据[“您的电子邮件”];
$subscribe_email=$wpcf7->posted_数据[“您的电子邮件”];
如果($subscribe_news){ktmcf7_submit_mailchimp($subscribe_email)}
如果($subscribe_blog){ktmcf7_submit_feedburner($subscribe_email)}
}
功能ktmcf7_提交_feedburner($subscribe_email){
$options=get_option('ktm_singlesub_options');
?>
警报(“feedburner”);
打开窗户http://feedburner.google.com/fb/a/mailverify?uri='、'popup5'、'滚动条=是,宽度=550,高度=520';

理论上,您不希望输出表单,而是希望使用HTTP post将表单变量提交到FeedBurners端点,并使用wp_u函数发出HTTP post

以下代码实现了一个WordPress插件,该插件将从联系人表单7的
wpcf7\u-before\u-send\u-mail
事件处理程序发出HTTP POST:

function wpcf7_do_something (&$WPCF7_ContactForm) {
    $url = 'http://your-end-point';
    $email = $WPCF7_ContactForm->posted_data['email'];    
    $post_data = array(
         'email' => urlencode($email),
         'feedburner_id' => urlencode($feedburner_id));

    $result = wp_remote_post( $url, array( 'body' => $post_data ) );
}

add_action("wpcf7_before_send_mail", "wpcf7_do_something");

上述代码的工作原理与宣传的一样,但请记住,您可能还需要处理CSRF令牌。

理论上,您不希望输出表单,而是希望使用HTTP post将表单变量提交到FeedBurners端点,并使用wp_u函数发布HTTP post

以下代码实现了一个WordPress插件,该插件将从联系人表单7的
wpcf7\u-before\u-send\u-mail
事件处理程序发出HTTP POST:

function wpcf7_do_something (&$WPCF7_ContactForm) {
    $url = 'http://your-end-point';
    $email = $WPCF7_ContactForm->posted_data['email'];    
    $post_data = array(
         'email' => urlencode($email),
         'feedburner_id' => urlencode($feedburner_id));

    $result = wp_remote_post( $url, array( 'body' => $post_data ) );
}

add_action("wpcf7_before_send_mail", "wpcf7_do_something");
上面的代码与广告中的一样有效,但请记住,您可能还需要处理CSRF令牌