Skip to main content
Updated
Source Link

I think for your requirement you need to overwrite the Magento_Contact Post controller. By default Magento_Contact module redirects to contact/index after you submit the Contact Form. Follow these steps to overwrite.

Added to your custom module di.xml

<preference for="Magento\Contact\Controller\Index\Post" type="[Name Space]\[Your Module]\Controller\Contact\Post" />

Create the custom controller class

<?php
           
namespace [Name Space]\[Your Module]\Controller\Contact\Post;
 
class Post extends \Magento\Contact\Controller\Index\Post
 
{
 
public function execute($coreRoute = null)
 
{
 
    if (!$this->getRequest()->isPost()) {
        return $this->resultRedirectFactory->create()->setPath('*/*/');
 todo   }
    try {
        $this->sendEmail($this->validatedParams());
        $this->messageManager->addSuccessMessage(
            __('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.')
        );        
    } catch (LocalizedException $e) {
        $this->messageManager->addErrorMessage($e->getMessage());     
    } catch (\Exception $e) {
        $this->logger->critical($e);
        $this->messageManager->addErrorMessage(
            __('An error occurred while processing your form. Please try again later.')
        );      
    }
    return $this->resultRedirectFactory->create()->setPath('<Your Module Frontend Page Path>');
 
}     
}

"Your Module Frontend Page Path" something like custom-module/success

Refer the class for details.

/vendor/magento/module-contact/Controller/Index/Post.php

By overwriting the execute function you re-direct to the new custom page template.

How to create a Custom Page

Please check here.

Hope this answer is helpful.

I think for your requirement you need to overwrite the Magento_Contact Post controller. By default Magento_Contact module redirects to contact/index after you submit the Contact Form. Follow these steps to overwrite.

Added to your custom module di.xml

<preference for="Magento\Contact\Controller\Index\Post" type="[Name Space]\[Your Module]\Controller\Contact\Post" />

Create the custom controller class

<?php
           
namespace [Name Space]\[Your Module]\Controller\Contact\Post;
 
class Post extends \Magento\Contact\Controller\Index\Post
 
{
 
public function execute($coreRoute = null)
 
{
 
    // todo
 
}     
}

Refer the class for details.

/vendor/magento/module-contact/Controller/Index/Post.php

By overwriting the execute function you re-direct to the new custom page template.

Hope this answer is helpful.

I think for your requirement you need to overwrite the Magento_Contact Post controller. By default Magento_Contact module redirects to contact/index after you submit the Contact Form. Follow these steps to overwrite.

Added to your custom module di.xml

<preference for="Magento\Contact\Controller\Index\Post" type="[Name Space]\[Your Module]\Controller\Contact\Post" />

Create the custom controller class

<?php
           
namespace [Name Space]\[Your Module]\Controller\Contact\Post;
 
class Post extends \Magento\Contact\Controller\Index\Post
 
{
 
public function execute($coreRoute = null)
 
{
 
    if (!$this->getRequest()->isPost()) {
        return $this->resultRedirectFactory->create()->setPath('*/*/');
    }
    try {
        $this->sendEmail($this->validatedParams());
        $this->messageManager->addSuccessMessage(
            __('Thanks for contacting us with your comments and questions. We\'ll respond to you very soon.')
        );        
    } catch (LocalizedException $e) {
        $this->messageManager->addErrorMessage($e->getMessage());     
    } catch (\Exception $e) {
        $this->logger->critical($e);
        $this->messageManager->addErrorMessage(
            __('An error occurred while processing your form. Please try again later.')
        );      
    }
    return $this->resultRedirectFactory->create()->setPath('<Your Module Frontend Page Path>');
 
}     
}

"Your Module Frontend Page Path" something like custom-module/success

Refer the class for details.

/vendor/magento/module-contact/Controller/Index/Post.php

By overwriting the execute function you re-direct to the new custom page template.

How to create a Custom Page

Please check here.

Hope this answer is helpful.

Updated
Source Link

I think for your requirement you need to overwrite the Magento_Contact Post controller. By default Magento_Contact module redirects to contact/index after you submit the Contact Form. Follow these steps to overwrite.

Added to your custom module di.xml

<preference for="Magento\Contact\Controller\Index\Post" type="[Name Space]\[Your Module]\Controller\Contact\Post" />

Create the custom controller class

<?php
           
namespace [Name Space]\[Your Module]\Controller\Contact\Post;
 
class Post extends \Magento\Contact\Controller\Index\Post
 
{
 
public function execute($coreRoute = null)
 
{
 
    // todo
 
}     
}

Refer the class for details.

/vendor/magento/module-contact/Controller/Index/Post.php

By overwriting the execute function you re-direct to the new custom page template.

Hope this answer is helpful.

I think for your requirement you need to overwrite the Magento_Contact Post controller. By default Magento_Contact module redirects to contact/index after you submit the Contact Form. Follow these steps to overwrite.

Added to your custom module di.xml

<preference for="Magento\Contact\Controller\Index\Post" type="[Name Space]\[Your Module]\Controller\Contact\Post" />

Create the custom controller class

<?php
           
namespace [Name Space]\[Your Module]\Controller\Contact\Post;
 
class Post extends \Magento\Contact\Controller\Index\Post
 
{
 
public function execute()
 
{
 
    // todo
 
}     
}

Refer the class for details.

/vendor/magento/module-contact/Controller/Index/Post.php

By overwriting the execute function you re-direct to the new custom page template.

Hope this answer is helpful.

I think for your requirement you need to overwrite the Magento_Contact Post controller. By default Magento_Contact module redirects to contact/index after you submit the Contact Form. Follow these steps to overwrite.

Added to your custom module di.xml

<preference for="Magento\Contact\Controller\Index\Post" type="[Name Space]\[Your Module]\Controller\Contact\Post" />

Create the custom controller class

<?php
           
namespace [Name Space]\[Your Module]\Controller\Contact\Post;
 
class Post extends \Magento\Contact\Controller\Index\Post
 
{
 
public function execute($coreRoute = null)
 
{
 
    // todo
 
}     
}

Refer the class for details.

/vendor/magento/module-contact/Controller/Index/Post.php

By overwriting the execute function you re-direct to the new custom page template.

Hope this answer is helpful.

Source Link

I think for your requirement you need to overwrite the Magento_Contact Post controller. By default Magento_Contact module redirects to contact/index after you submit the Contact Form. Follow these steps to overwrite.

Added to your custom module di.xml

<preference for="Magento\Contact\Controller\Index\Post" type="[Name Space]\[Your Module]\Controller\Contact\Post" />

Create the custom controller class

<?php
           
namespace [Name Space]\[Your Module]\Controller\Contact\Post;
 
class Post extends \Magento\Contact\Controller\Index\Post
 
{
 
public function execute()
 
{
 
    // todo
 
}     
}

Refer the class for details.

/vendor/magento/module-contact/Controller/Index/Post.php

By overwriting the execute function you re-direct to the new custom page template.

Hope this answer is helpful.