2

Can you help me on how to modify the default success message like "Thank you for your registration" after you create an account or register an account in magento 2.1.1.

4 Answers 4

4

Create your own theme ( please check this link for create theme : http://devdocs.magento.com/guides/v2.1/frontend-dev-guide/themes/theme-create.html ) and in that create below file :

{Magento root}\app\design\frontend\{Your Vendor}\ {Your theme}\Magento_Customer\i18n\en_US.csv

in en_US.csv file add your own message :

"Thank you for registering with %1.","Thank you for your registration."
6
  • Hi Thank you for your answer. I really appreciate this I'll try this first. Nov 11, 2016 at 7:29
  • I have a question. I followed your instructions but still the same the success message is is still the same. Nov 11, 2016 at 7:43
  • please clear cache and also run this command php bin/magento setup:static-content:deploy
    – user46386
    Nov 11, 2016 at 8:45
  • Thanks I'll try again with the one you suggest. sorry I forgot to do that earlier. Nov 11, 2016 at 12:32
  • This didn't seem to work for me in Magento 2.2.1 - anyone else have issue? Nov 22, 2017 at 11:20
1

You have to override controller file in your module.

vendor/magento/module-customer/Controller/Account/CreatePost.php

After overrider above file changes in getSuccessMessage() function, You can change your message in below functiom.

Path for di.xml file, app/code/Vendor/Modulename/etc/frontend/

di.xml file,

<?xml version="1.0"?>

<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento\Customer\Controller\Account\CreatePost"
                type="Vendor\Modulename\Controller\Account\CreatePost" />
</config>

Path for controller override, Vendor\Modulename\Controller\Account

CreatePost.php file

<?php
namespace Vendor\Modulename\Controller\Account;

class CreatePost extends \Magento\Customer\Controller\Account\CreatePost{   
    protected function getSuccessMessage()
    {
        if ($this->addressHelper->isVatValidationEnabled()) {
            if ($this->addressHelper->getTaxCalculationAddressType() == Address::TYPE_SHIPPING) {
                // @codingStandardsIgnoreStart
                $message = __(
                    'If you are a registered VAT customer, please <a href="%1">click here</a> to enter your shipping address for proper VAT calculation.',
                    $this->urlModel->getUrl('customer/address/edit')
                );
                // @codingStandardsIgnoreEnd
            } else {
                // @codingStandardsIgnoreStart
                $message = __(
                    'If you are a registered VAT customer, please <a href="%1">click here</a> to enter your billing address for proper VAT calculation.',
                    $this->urlModel->getUrl('customer/address/edit')
                );
                // @codingStandardsIgnoreEnd
            }
        } else {
         //your custom message...
            $message = __('Thank you for registering with us');
        }
        return $message;
    }
}
4
  • Hello Rakesh, Thanks for this I'll try this first Nov 11, 2016 at 7:20
  • Have you try with this? Nov 11, 2016 at 8:00
  • upgrade,compile,deploy are required Dec 17, 2018 at 11:30
  • Not working I m trying this
    – Rv Singh
    May 16, 2019 at 14:39
1

di.xml:

<preference for="Magento\Customer\Controller\Account\CreatPost"
            type="<namespace>\<module_name>\Controller\Account\CreatPost" />

Override controller method(Magento\Customer\Controller\Account):

/**
 * Retrieve success message
 *
 * @return string
 */
protected function getSuccessMessage()
{
    if ($this->addressHelper->isVatValidationEnabled()) {
        if ($this->addressHelper->getTaxCalculationAddressType() == Address::TYPE_SHIPPING) {
            // @codingStandardsIgnoreStart
            $message = __(
                'If you are a registered VAT customer, please <a href="%1">click here</a> to enter your shipping address for proper VAT calculation.',
                $this->urlModel->getUrl('customer/address/edit')
            );
            // @codingStandardsIgnoreEnd
        } else {
            // @codingStandardsIgnoreStart
            $message = __(
                'If you are a registered VAT customer, please <a href="%1">click here</a> to enter your billing address for proper VAT calculation.',
                $this->urlModel->getUrl('customer/address/edit')
            );
            // @codingStandardsIgnoreEnd
        }
    } else {
        $message = __('Thank you for registering with %1.', $this->storeManager->getStore()->getFrontendName());
    }
    return $message;
}
7
  • Hello Ronak, Thank you for your answer also. I'll try your approach also thanks again Nov 11, 2016 at 7:20
  • 2
    @ronak this is not proper method we can do this with the help of translation
    – user46386
    Nov 11, 2016 at 7:32
  • Translation is another way to do so, but This is proper method to override anything of core module. Nov 11, 2016 at 7:58
  • Ok Ronak, I'll try also your approach. I'll feedback later if it will really work in my end. Thanks Nov 11, 2016 at 12:33
  • my pleasure brother. Happy to help. @MazeStricks Nov 11, 2016 at 12:34
0

I am using Magento 2.4.5p1 latest version & following approach works fine for me.

Step 1: Create an i18n folder & an en_US.csv file under your custom theme.

File Path: app/design/frontend/Your Vendor/your theme name/i18n/en_US.csv

Step 2: In the en_US.csv file add the below translation. I have added a translation for the customer register success message. Please note, I have mentioned "module" keyword & actual module name to inform Magento regarding our custom translation.

"You must confirm your account. Please check your email for the confirmation link or <a href=""%1"">click here for a new link.","You must confirm your account. Please check your email for the confirmation link or <a href=""%1"">click here for a new link. Please check your spam if the email is not received.",module,Magento_Customer,

Step 3: Clear cache & check. If still not reflecting clear static content deploy & check.

If your Magento has multiple language setups, create respected translations using the above first step. I have made a nb_NO.csv file as well for the Norwegian language.

"You must confirm your account. Please check your email for the confirmation link or <a href=""%1"">click here for a new link.","Du må bekrefte kontoen din. Vennligst sjekk e-posten din for bekreftelseslenken eller <a href=""%1"">klikk her for en ny lenke. Vennligst sjekk spam hvis e-posten ikke er mottatt.",module,Magento_Customer,

If you want to translate any theme text to other languages, add the line below. In my case Norwegian language(nb_NO.csv). Clear cache & check.

"SHIPPING ADDRESS:","SENDINGSADRESSE:","theme","frontend/Your Vendor/your theme name",

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.