与Wordpress的Mailchimp时事通讯注册

时间:2016-01-18 20:51:46

标签: php html wordpress mailchimp

我一直在尝试设置一个可以在我的wordpress博客上运行的Mailchimp简报注册。

我似乎无法找到一个小工具,它会在我博客的侧边栏中安装一个注册框,并实际将用户添加到我的mailchimp邮件列表中。

我的要求是,我只是希望用户能够输入他们的姓名和电子邮件地址,点击订阅,获得一条小小的弹出消息,感谢用户订阅然后宾果游戏,他们已经添加到邮件列表中。

那里有什么可以解决的问题吗?

我已经尝试创建注册并嵌入mailchimp给我的HTML代码到我博客的sidebar.php部分。我已经从嵌入代码中禁用了javascript,因为这显然会导致问题。

现在,注册框将出现在页面上,但是当我填写字段并单击提交时,页面只会刷新并在地址栏中吐出一堆代码,例如...

http://ch-designs.co.uk/wordpress/?widget-jal_widget%5B2%5D%5Bfx_in%5D=slideDown&widget-jal_widget%5B2%5D%5Bex_sym%5D=%E2%96%BA&widget-jal_widget%5B2%5D%5Bcon_sym%5D=%E2%96%BC&widget-jal_widget%5B2%5D%5Bonly_sym_link%5D=1&ns_widget_mailchimp_first_name=&ns_widget_mailchimp_last_name=&ns_mc_number=3&ns_widget_mailchimp_email=&Subscribe=Subscribe

我只想说它不会将任何人添加到我的邮件列表中。

非常感谢任何帮助。感谢。

修改

我已经尝试了以下解决方案,但现在我被重新定向到404:页面未找到mailchimp页面。

这是我的代码......

 <div id="mc_embed_signup">
    <form action="//ch-designs.us12.list-manage.com/subscribe/post-json?u=a0496f5489571ea6dbdf57077&amp;id=a292e14b56&c=?" method="get" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate>
    <div id="mc_embed_signup_scroll">
    <h2>Subscribe to our mailing list</h2>
<div class="indicates-required"><span class="asterisk">*</span> indicates required</div>
<div class="mc-field-group">
    <label for="mce-EMAIL">Email Address  <span class="asterisk">*</span>
</label>
    <input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL">
</div>
<div class="mc-field-group">
    <label for="mce-FNAME">First Name </label>
    <input type="text" value="" name="FNAME" class="" id="mce-FNAME">
</div>
<div class="mc-field-group">
    <label for="mce-LNAME">Last Name </label>
    <input type="text" value="" name="LNAME" class="" id="mce-LNAME">
</div>
    <div id="mce-responses" class="clear">
        <div class="response" id="mce-error-response" style="display:none"></div>
        <div class="response" id="mce-success-response" style="display:none"></div>
    </div>    <!-- real people should not fill this in and expect good things - do not remove this or risk form bot signups-->
    <div style="position: absolute; left: -5000px;" aria-hidden="true"><input type="text" name="b_a0496f5489571ea6dbdf57077_a292e14b56" tabindex="-1" value=""></div>
    <div class="clear"><input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button"></div>
    </div>
</form>
</div>
    <script>

$(document).ready( function () {
    // I only have one form on the page but you can be more specific if need be.
    var $form = $('form');

    if ( $form.length > 0 ) {
        $('form input[type="submit"]').bind('click', function ( event ) {
            if ( event ) event.preventDefault();
            // validate_input() is a validation function I wrote, you'll have to substitute this with your own.
            if ( validate_input($form) ) { register($form); }
        });
    }
});

function register($form) {
    $.ajax({
        type: $form.attr('method'),
        url: $form.attr('action'),
        data: $form.serialize(),
        cache       : false,
        dataType    : 'json',
        contentType: "application/json; charset=utf-8",
        error       : function(err) { alert("Could not connect to the registration server. Please try again later."); },
        success     : function(data) {
            if (data.result != "success") {
                // Something went wrong, do something to notify the user. maybe alert(data.msg);
            } else {
                // It worked, carry on...
            }
        }
    });
}
</script>

2 个答案:

答案 0 :(得分:1)

我遇到了同样的问题,但似乎并没有很多相关信息。我只是试图让表单在没有刷新和页面直接的情况下工作。我在使用ajax的Stack上找到了一个很好的答案。这个表格对我有用,而且很容易实现。您可以使用标准代码进行一些小的更改。添加一些ajax,你很高兴。您也可以使用css进行相应的样式设置。问题和代码的链接位于ajax mailchimp signup form integration

答案 1 :(得分:0)

将表单网址更改为

http://ch-designs.us12.list-manage.com/subscribe/post-json?u=a0496f5489571ea6dbdf57077&amp;id=a292e14b56&

希望这有助于:)