WordPress.org

Ready to get started?Download WordPress

Forums

MailChimp List Subscribe Form
Please add an action to the form for plugins to hook into (2 posts)

  1. Jeremy Clarke
    Member
    Posted 2 years ago #

    Hi there, still integrating your plugin, and I love it! It works just like it should in so many ways. This request is for something that is definitely above-and-beyond the basics but would be very easy to implement and very unlikely to cause issues for people who don't use it.

    What I'd like is a custom WordPress API action/filter that fires at some point during the output of the subscribe form ( mailchimpSF_signup_form() ) that I could hook into with my custom plugin/functions.php code to do extra stuff.

    It could be as simple as adding this one line at the bottom of mailchimpSF_signup_form():

    do_action('mailchimpSF_signup_form');

    In my case what I want to do is add some jQuery code to select the first "group" radio input by default, but I only want to add the jquery when the form has actually been shown on the page (to avoid running it unnecessarily).

    If there was an action in mailchimpSF_signup_form() then I could either show the jQuery there, or else attach a callback to wp_footer during your hook, and output the jQuery later. Having an action would also let me avoid having to do awkward checks to see if the MailChimp plugin is even active, since if I ran my code on your action then it would all fail gracefully if the action just never got fired. Currently I have to use a function_exists() check, which is not dependable because you might change the names of the function I check for.

    Ideally all content in WP should be accompanied by actions and also filters. In your case adding a filter the subscribe form output would be a TON of work because currently it echos things directly rather than assigning them to a variable first, so I won't push that one too hard ;) You may want to consider other places in your code that could use actions though (like before submitting to the API). If you've developed for WP you know how powerful the API can be, adding that power to your plugin will make it enterprise grade :)

    Thanks for considering this request, keep up the good work!

    P.S. An alternative that would solve my problem but maybe not as many other people's would be to set a constant (like MAILCHIMPSF_SIGNUP_FORM_USED) to true after the form is output. If you did that I could check the constant in wp_footer and act based on that. Not really any simpler than the action and much less powerful, but maybe more appealing to you for whatever reason.

    http://wordpress.org/extend/plugins/mailchimp/

  2. mc_nate
    Member
    Posted 2 years ago #

    Hey Jeremy,

    I didn't want to leave you hanging for so long. This is something that we can most definitely pass along to the devs, but unfortunately, we don't have a timeline for this sort of thing.

    In the meantime, if we can help with anything else, please don't hesitate to give us a shout.

    Cheers

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags