We sacrifice by not doing any other technology, so that you get the best of Magento.

We sacrifice by not doing any other technology, so that you get the best of Magento.

    We can do it by using preference if we need to add or edit some information in createPost controller.

    To do that we will need a module : Magemonkeys_General

    We have need two files.

    Create di.xml file in this folder app/code/Magemonkeys/General/etc/

    <?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="MagentoCustomerControllerAccountCreatePost" type="MagemonkeysGeneralControllerMagentoCustomerAccountCreatePost" />
    </config>

    Create CreatePost.php in this folder app/code/Magemonkeys/General/Controller/Magento/Customer/Account/

    <?php
    
    namespace MagemonkeysGeneralControllerMagentoCustomerAccount;
    use MagentoCustomerApiCustomerRepositoryInterface as CustomerRepository;
    use MagentoFrameworkAppActionHttpPostActionInterface as HttpPostActionInterface;
    use MagentoCustomerModelAccountRedirect as AccountRedirect;
    use MagentoCustomerApiDataAddressInterface;
    use MagentoFrameworkApiDataObjectHelper;
    use MagentoFrameworkAppActionContext;
    use MagentoCustomerModelSession;
    use MagentoFrameworkAppConfigScopeConfigInterface;
    use MagentoFrameworkAppCsrfAwareActionInterface;
    use MagentoFrameworkAppObjectManager;
    use MagentoFrameworkAppRequestInvalidRequestException;
    use MagentoFrameworkAppRequestInterface;
    use MagentoFrameworkControllerResultRedirect;
    use MagentoFrameworkExceptionLocalizedException;
    use MagentoFrameworkPhrase;
    use MagentoStoreModelStoreManagerInterface;
    use MagentoCustomerApiAccountManagementInterface;
    use MagentoCustomerHelperAddress;
    use MagentoFrameworkUrlFactory;
    use MagentoCustomerModelMetadataFormFactory;
    use MagentoNewsletterModelSubscriberFactory;
    use MagentoCustomerApiDataRegionInterfaceFactory;
    use MagentoCustomerApiDataAddressInterfaceFactory;
    use MagentoCustomerApiDataCustomerInterfaceFactory;
    use MagentoCustomerModelUrl as CustomerUrl;
    use MagentoCustomerModelRegistration;
    use MagentoFrameworkEscaper;
    use MagentoCustomerModelCustomerExtractor;
    use MagentoFrameworkExceptionStateException;
    use MagentoFrameworkExceptionInputException;
    use MagentoFrameworkDataFormFormKeyValidator;
    use MagentoCustomerControllerAbstractAccount;
    
    class CreatePost extends MagentoCustomerControllerAccountCreatePost
    {
    	/**
         * @var Validator
         */
        private $formKeyValidator;
        protected $inlineTranslation;
    
        /**
         * @var MagentoFrameworkStdlibCookiePhpCookieManager
         */
        private $cookieMetadataManager;
    
        /**
         * @var MagentoFrameworkStdlibCookieCookieMetadataFactory
         */
        private $cookieMetadataFactory;
    
        public function __construct(
        	Context $context,
            Session $customerSession,
            ScopeConfigInterface $scopeConfig,
            StoreManagerInterface $storeManager,
            AccountManagementInterface $accountManagement,
            Address $addressHelper,
            UrlFactory $urlFactory,
            FormFactory $formFactory,
            SubscriberFactory $subscriberFactory,
            RegionInterfaceFactory $regionDataFactory,
            AddressInterfaceFactory $addressDataFactory,
            CustomerInterfaceFactory $customerDataFactory,
            CustomerUrl $customerUrl,
            Registration $registration,
            Escaper $escaper,
            CustomerExtractor $customerExtractor,
            DataObjectHelper $dataObjectHelper,
            AccountRedirect $accountRedirect,
            CustomerRepository $customerRepository,
            Validator $formKeyValidator = null
        ) {
        	$this->formKeyValidator = $formKeyValidator ?: ObjectManager::getInstance()->get(Validator::class);
            $this->accountRedirect = $accountRedirect;
        	return parent::__construct($context,$customerSession,$scopeConfig,$storeManager,$accountManagement,$addressHelper,$urlFactory,$formFactory,$subscriberFactory,$regionDataFactory,$addressDataFactory,$customerDataFactory,$customerUrl,$registration,$escaper,$customerExtractor,$dataObjectHelper,$accountRedirect,$customerRepository,$formKeyValidator);
        }
    
    	public function execute()
        {          
            /** @var Redirect $resultRedirect */
            $resultRedirect = $this->resultRedirectFactory->create();
            if ($this->session->isLoggedIn() || !$this->registration->isAllowed()) {
                $resultRedirect->setPath('*/*/');
                return $resultRedirect;
            }
    
            // We can write our login here
        }
    }

    we will also need to add private function in this file as we used execute method.

    /**
         * Retrieve cookie manager
         *
         * @deprecated 100.1.0
         * @return MagentoFrameworkStdlibCookiePhpCookieManager
         */
        private function getCookieManager()
        {
            if (!$this->cookieMetadataManager) {
                $this->cookieMetadataManager = ObjectManager::getInstance()->get(
                    MagentoFrameworkStdlibCookiePhpCookieManager::class
                );
            }
            return $this->cookieMetadataManager;
        }

    That’s it.

    field_5bfb909c5ccae

      Get a Free Quote