skip to Main Content

I want to show a custom message if user already subscribed with a email address.
like

You are already subscribed. Thank you.

Instead of this message.

enter image description here

I am using magento2.1.8.

2

Answers


  1. You should define a preference (via di.xml) for the OOTB Controller that handles the Subscription sign-up process (Magento/Newsletter/Controller/Subscriber/NewAction.php) and in your custom controller’s execute method – add the desired logic to check whether/not the customer has already subscribed and handle it accordingly.

    Subscription Sign-up Code/Logic

    Login or Signup to reply.
  2. You need to modify this simple checking.

    Try this –

    Go to this path if you haven’t override NewAction.php file yet vendormagentomodule-newsletterControllerSubscriber and open NewAction.php file.

    Replace this code:

    if ($subscriber->getId() && $subscriber->getSubscriberStatus() == MagentoNewsletterModelSubscriber::STATUS_SUBSCRIBED)
    

    With:

    if($subscriber->getId())
    

    That’s all.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search