I have seen plenty of solutions for Magento 1.9, but I have not been able to find any conclusive way of disabling user accounts for Magento 2.
I'm developing a custom theme whose parent is Magento/blank
.
I have no problem removing the login,signup,wishlist etc. from the frontend using XML and I've managed to remove any mention of customer accounts from the orders page (though I don't remember which process I followed to do so).
However, when my site loads I get an error in the console: Password fields present on an insecure (http://) page. This is a security risk that allows user login credentials to be stolen
. Further, if the site is rendered as plain html then the login form is visible.
There will never be any customer accounts allowed on the store, so I'd like to remove all references to accounts on all pages.
I have followed 7ochem's answer to create a custom module for registration removal, modified for Magento 2 as follows:
app/code/[Vendor_name]/[Module_name]/registration.php
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'[Vendor_name]_[Module_name]',
__DIR__
);
app/code/[Vendor_name]/[Module_name]/etc/module.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="[Vendor_name]_[Module_name]" setup_version="1.0.0">
<sequence>
<module name="Magento_Customer"/>
</sequence>
</module>
</config>
app/code/[Vendor_name]/[Module_name]/Plugin/RegistrationPlugin.php
namespace [Vendor_name]\[Module_name]\Plugin;
use Magento\Customer\Model\Registration;
class RegistrationPlugin
{
/**
* @param Registration $subject
*/
public function afterIsAllowed(Registration $subject)
{
return false;
}
}
Using the code inspector (firefox-aurora), I can see a script which contains the variable window.authenticationPopup = ...
, so I presume that this module is not working properly.
EDIT:
Following JoshCarter's comments, I have added the following file:
app/code/[Vendor_name]/[Module_name]/etc/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Customer\Model\Registration">
<plugin name="[Vendor_name]_[Module_name]::after" type="[Vendor_name]\[Module_name]\Plugin\RegistrationPlugin"/>
</type>
</config>
After uploading this to the server, I executed the following commands:
$ php bin/magento indexer:reindex
$ php bin/magento setup:upgrade
$ php bin/magento setup:di:compile
During compilation, I receive the following error:
[InvalidArgumentException] Plugin class [Vendor_name][Module_name]\Plugin\RegistrationPlugin doesn't exist.