0

I am making users programmatically (weird system that a company wants, where users send their details to company's email, they then create user in their CRM, and upload users data to server, where I pick it up and create user from it), and the problem is, that password shorter than 6 characters are not allowed. I've updated this in administration, and that seems to only work when users register in the frontend.

How can I set minimum password length for users I am making in the backend?

Example of code that creates user:

    $CustomerModel = $objectManager->create('Magento\Customer\Model\Customer');


    $CustomerModel->setWebsiteId(1); 
    $CustomerModel->loadByEmail($email);

    if (!$CustomerModel->getId()) {
        $customer = $customerFactory->create();
        $customer->setWebsiteId($websiteId);

        $customer->setEmail($email);
        $customer->setFirstname($name);
        $customer->setPassword($password);
        $customer->save();
    }
0

Go to :

/vendor/magento/module-customer/Model/Customer/Attribute/Backend/Password.php

const MIN_PASSWORD_LENGTH = 6;

You can change password length from here.

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.