Skip to main content
Tweeted twitter.com/StackMagento/status/1070739868677013505
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
Source Link
tecjam
  • 4k
  • 3
  • 27
  • 48

Is it possible to redirect the Magento 2 Contact Form without a custom module?

I'm trying to get the Magento 2 Contact form to redirect not to /contact/index but someplace else. Here is what I have so far:

We use a custom theme, in which I have created a the following folders

Magento_Contact -email -submitted_form.html -templates - form.phtml

I've edited the form.phtml to add / edit the fields as required.

I've created a content block and added the form to it with:

{{block class="Magento\Contact\Block\ContactForm" name="contactForm" template="Magento_Contact::form.phtml"}}

And I've created a CMS Page with this block in it, using

{{block class="Magento\\Cms\\Block\\Block" block_id="myContact"}}

Now I want to the user to stay on that CMS Page after submitting the form, so I presume I will need to change $this->_redirect('contact/index'); to $this->_redirect('*/*/'); in the modules post controller.

I was wondering if there wasn't a quicker way to add the redirect, maybe as a block comment or similar.

Thank you.