Is it possible to subscribe to a newsletter without the user having to create an account? So on a page have some fields, like email, name etc and store them in the newsletter data?

How would I do something like that?

My form code:

<? $pageid =  Mage::getBlockSingleton('cms/page')->getPage()->getId();

  if($pageid == '20'){
    echo '
    <form id="contact-form" action="https://natuurgroothandel.com/nieuwsbrief.php" method="post" class="contact_form row contact-form" role="form">
        <p class="col-sm-12 kl-fancy-form">
          <label class="control-label">Naam</label>
          <input type="text" name="name" class="form-control form-control-name" value="" tabindex="1" maxlength="35">
        <p class="col-sm-12 kl-fancy-form">
          <label class="control-label">Geslacht</label>
          <input type="text" name="gender" class="form-control form-control-email h5-email" value="" tabindex="1" maxlength="35">
        <p class="col-sm-12 kl-fancy-form">
          <label class="control-label">Geboortedatum</label>
          <input type="text" name="date" class="form-control form-control-phone" value="" tabindex="1" maxlength="35">
        <p class="col-sm-12 kl-fancy-form">
          <label class="control-label">Emailadres</label>
          <input type="text" name="email" class="form-control form-control-phone" value="" tabindex="1" maxlength="35" required>
        <div class="col-sm-12">
          <div class="error-container"></div>
        <p class="col-sm-12">
          <button class="btn btn-fullcolor" type="submit">Verzenden</button>
  • you need to take all required field from page and make it entry in all table that affect to this functionality. – Dhiren Vasoya Aug 23 '17 at 10:05
  • @DhirenVasoya Can you explain a little more detailed? – twan Aug 23 '17 at 10:08
  • In default magento, when newsletter subscribe, at that time magento it self place entry in some table. You need to do same things here using custom code. – Dhiren Vasoya Aug 23 '17 at 10:10

You can use this code to do this. Put this code in your controller action of form submission:

$email = $this->getRequest()->getPost('email_input_name');

        $subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email);

        /* checking if customer is already subscribed or unsubscribed */
        if($subscriber->getStatus() != Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED &&
            $subscriber->getStatus() != Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED
                // return or redirect to any page you want
            catch (Exception $e)
  • Thank you, do you have an example of this working with a form? – twan Aug 23 '17 at 11:31
  • I used this code in an observer for order_place_after event.. you can have a simple html form with action="<?php echo Mage::getUrl('module/controller/action') ?>" and place this code in your action method. – Yogesh Agarwal Aug 24 '17 at 6:10
  • Alright, where can I add the above code? I got a form only on the page I want and added the line in your above comment, but I don't see the maps: module/controller/action @Sachin Agarwal – twan Aug 24 '17 at 9:21
  • Do I need to create a module for this? I am really new to magento coding. – twan Aug 24 '17 at 9:25
  • @twan can you please add your form code in the question? – Yogesh Agarwal Aug 24 '17 at 10:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.