Skip to content

Using a WordPress registration form to subscribe to a list?

edited October 2014 in Questions

Is it possible to make a WordPress "new user" signup box send its email address to Sendy, if the user checks a subscribe box? I've got the checkbox showing already (see here: https://www.hilarydruxman.com/my-account/), I just don't know how to wire that into Sendy itself... or if that's even possible. Does anyone know how to make it so that when the form is submitted, check to see if the checkbox is selected and then send the email address to a list in Sendy?

Thanks!

Comments

  • Hi,

    Maybe this Wordpress plugin is what you're looking for http://wordpress.org/plugins/sync-to-sendy/

    There're many other Wordpress plugins, look under 'Third party resources' at http://sendy.co/api. You can also use Sendy's 'subscribe' API to subscribe users programmatically which will satisfy any scenario.

    Thanks.

    Best regards,
    Ben

  • Thanks, Ben! There are some good resources there that I hadn't seen elsewhere. I ended up solving my problem with jQuery, though. Here's the code I added to functions.php:

    add_filter( 'register_form', 'adding_custom_registration_fields' );
        function adding_custom_registration_fields( ) {
    
                echo '<div class="form-row form-row-wide"><label for="reg_subscribe"><input type="checkbox" name="reg_subscribe" id="reg_subscribe" value="" />Subscribe to the newsletter</label></div>';
    
            // email of the person being added to the email list
            $sendy_email = $_POST['email'];
    
            $url = "https://www.yourdomain.com/sendy/subscribe/$sendy_email/1/";
            ?>
    <script>
        jQuery( ".register" ).submit(function() {
            var user_email = jQuery("#reg_email").val();
    
            if(jQuery('#reg_subscribe').is(':checked')) {
              jQuery.post( "https://www.yourdomain.com/sendy/subscribe/"+ user_email +"/1/" );
                    }
    </script>
    
    <?php
    }
    

    If others are using this with their WooCommerce setup too, make sure you change that last URL so "yourdomain" is your domain, and the /1/ at the end is your list ID. I hope that helps someone else! :)

This discussion has been closed.