0

I want to create a custom register form.

But, the user can only create an account if he is in my XML File.

For now, I get the information of the user from my XML.

Then I want to use this information to create the account, but the user only needs to add his name, mail and password (the other information will fit into the database automatically with info from XML (like address, country...)).

But I don't know where to start,

Any Guidance will be appreciated. Thanks in Advance.

EDIT : i believe that the answer to my question is something like this How to add a customer programmatically in Magento 2?

But when I try do add something in my constructor, I have a white page and that's all.

Here's my code :

<?php
namespace Portail\Test\Controller\Connexion;

use Magento\Framework\App\Action\Action;
use Magento\Framework\App\Action\Context;
use Magento\Framework\App\ObjectManager;
use Magento\Framework\View\Result\PageFactory;
use Magento\Store\Model\StoreManagerInterface;

class Form extends Action
{
    protected $_pageFactory;
    protected $storeManager;

    public function __construct(Context $context,  StoreManagerInterface $storeManager, PageFactory $pageFactory)
    {
        $this->storeManager = $storeManager;
        $this->_pageFactory = $pageFactory;
        return parent::__construct($context);
    } 
...
    }

Without StoreManagerInterface $storeManager in constuctor i haven't white page

  • You need to save your users in data base or in some array, then your custom form before submit you check first if the name that the user entered is in database or that array if ok you submit, otherwise you do some Exception, diplay some Error message – PЯINCƏ May 24 '18 at 10:01
  • The user is not in the databases in the first place, I use XML to mock a webservice. If the user is filling the form, then I call the webservice and after the user infos will be in the database. – Morgan Tartreau May 24 '18 at 10:16
  • Are you using which platform for webservice? – Abdul May 24 '18 at 12:03
  • To mock server, i'm using this github.com/tomashanacek/mock-server. It create some file in XML, same than my webservice – Morgan Tartreau May 24 '18 at 12:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.