In Magento 2 we have newsletter functionality and we can hide the link from the customer account and hide from customer account create a form as well. That all working fine.

I want to hide the page or restrict the page URL "newsletter/manage", How can I disable this URL or restrict this URL?

Is anyone have an idea about it?

  • using .htaccess you can do it – fmsthird Mar 22 '19 at 8:08
  • any another way? in the newsletter module, I found one "dispatch" action in newsletter controller @ "vendor\magento\module-newsletter\Controller\Manage.php" should we can use plugin here? – Utsav Gupta Mar 22 '19 at 9:09

Dispatch function runs before execute function in Magento controller. So you can override this controller using preference and then you can return from contorller based on your condition in Dispatch function.

| improve this answer | |
  • in Dispatch function, How we can use the URL redirection? – Utsav Gupta Mar 22 '19 at 9:22
  • You can use Magento\Framework\Controller\ResultFactory; class – Mohit chauhan Mar 22 '19 at 9:34
  • one more thing I get "\Magento\Newsletter\Controller\Manage\Index" here we can override execute method and redirect it. does it make sense? – Utsav Gupta Mar 22 '19 at 9:42
  • Yes of course it should work. – Mohit chauhan Mar 22 '19 at 9:48

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.