0

I need to customize the message that is presented to the customer after his registration. I do not need to change only the message, but I need to show a different text if the user has checked a field in the registration form.

  • I think you need to override this controller vendor/magento/module-customer/Controller/Account/CreatePost.php – Khoa TruongDinh Oct 22 '19 at 4:03
0

You can use Observer here like

app/code/Vendor/Module/etc/events.xml

Content for this file is..

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="controller_action_predispatch_customer_account_createpost">
        <observer name="customer_account_create_post" instance="Vendor\Module\Observer\CreatePost" />
    </event>
</config>

app/code/Vendor/Module/Observer/CreatePost.php

Content for this file is..

<?php
namespace Vendor\Module\Observer;

use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Exception\LocalizedException;

class CreatePost implements ObserverInterface
{
    protected $messageManager;

    public function __construct(
        \Magento\Framework\Message\ManagerInterface $messageManager
    ) {
        $this->messageManager = $messageManager;
    }

    public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $condition = 'Your condition';

        if($condition){
            $this->messageManager->addSuccess(
                __("Custom message here!")
            );
        }

        return $observer;
    }  
}

Hope this is helful to you!

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.