Subscribe Email Input and Submit Button

Is there a way to place an email input and an input subscribe button in a theme template and have them auto subscribe to a group upon submission and to leave it as an input field and input button without the switch to a list of subscribed groups after submission and not changing for a logged in user or guest. I always want the subscribe field to look like an input field and button.

  • Milan

    Hello @marcusvmonroe05,

    I hope you are well today and thanks for asking us. :slight_smile:

    I must admin I am facing little bit difficulty in understanding your answer. Can you be kind enough to describe it with some more info or example screenshot from other website where you might have seen this in action ?

    If I summarize this then it seems you want email subscribe form and auto subscribe them in a list like mailchimp list or custom created groups in e newsletter ?

    Cheers,
    Milan

  • Marcus

    HI @milansavaliyaz
    I want guests and users to be able to subscribe to the default list by just submitting their email address in a text input field and then click an input button to submit the form and add their email to the newsletter default group.

    I want to use this in a theme template page without having the full functionality of the widget where it switches from an input field to a list of Newsletters the user is subscribed to, that breaks my template layout.

    Maybe something simple like this:
    '<form role="newsletter" method="get" action="<?php echo home_url( '/' ); ?>">
    <span>
    <input type="text" placeholder="Enter Your Email to Join our Newsletter'" aria-invalid="false" aria-required="true" name="newsletter" value="">
    </span>
    <input class="submit" type="submit" value="SUBSCRIBE">
    </form>'

  • Adam Czajczyk

    Hello Marcus,

    Thank you for this explanation.

    Currently this is not possible "out of the box" and a fair amount of custom coding would be necessary. This is because the subscription form is not a simple html form that you could just post via "POST" request to a script. It's validated and submitted via JS script and handled by wp-ajax.

    It could be possible to create your own subscribe widget (or shortcode) with a form that would behave differently than the default one, however it would require coding at least following elements (I think as an MU plugin preferably):

    - own widget/shortcode
    This could be based on "/e-newsletter/email-newsletter-files/class.wp_widgets.php" code. The first step then would be to copy this code, change the class name and then adjust code inside.

    You'll notice that's using a "subscribe_widget()" function. This function should also be replaced with a custom one so it should be replaced in "widget/shortcode" code and then the new one added to the custom code.

    - "subscribe_widget()" function
    Again, this could be based on original function but should be modified according to your needs. The original code is located in "/e-newsletter/e-newsletter.php" file.

    If you feel like giving it a try yourself, above information should give you a good start and you'll want to further analyse plugin's code. You may also want to post a question on our "Jobs & Pros" job board (please note: no WPMU DEV staff involved) here:

    https://premium.wpmudev.org/wordpress-development/

    Having said that, I do see the point of using such a way to subscribe and I agree this would make a great feature so I'm moving this thread to our "Features and Feedback" forum. Hopefully more members of our community will support the idea so our developers then will add a new "simple" widget and/or shortcode to the plugin.

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.