Skip to content

Commit

Permalink
fists commit
Browse files Browse the repository at this point in the history
  • Loading branch information
salgua committed Sep 7, 2016
0 parents commit 1af626a
Show file tree
Hide file tree
Showing 7 changed files with 100 additions and 0 deletions.
33 changes: 33 additions & 0 deletions Plugin/RegistrationPlugin.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/**
* Copyright (c) 2016 Salvatore Guarino. All rights reserved.
*/

namespace Deved\DisableRegistration\Plugin;

use Magento\Customer\Model\Registration;

class RegistrationPlugin
{
/**
* @var \Magento\Framework\App\Config\ScopeConfigInterface
*/
protected $scopeConfig;
const XML_PATH_DISABLE_CUSTOMER_REGISTRATION = 'customer/create_account/disable_customer_registration';

public function __construct(\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig)
{
$this->scopeConfig = $scopeConfig;
}

public function afterIsAllowed(Registration $subject)
{
$storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORE;

if ($this->scopeConfig->getValue(self::XML_PATH_DISABLE_CUSTOMER_REGISTRATION, $storeScope))
{
return false;
}
return true;
}
}
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Magento 2 disable customer registration
This extension allows you to disable the customer registration in your Magento store.
It can be very useful in cases where Admin wants to create account for customers (B2B) and do not want to show the
default Registration form & link on his Magento store

## Installation
Shortly available
24 changes: 24 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "deved/magento2-disable-customer-registration",
"description": "Disable Customer registration",
"type": "magento2-module",
"version": "1.0.0",
"license": "MIT",
"authors": [
{
"name": "Salvatore Guarino",
"email": "[email protected]"
}
],
"require": {
"php": "~5.5.0|~5.6.0|~7.0.0",
"magento/framework": "~100.0",
"magento/module-customer": "~100.0"
},
"autoload": {
"files": [ "registration.php" ],
"psr-4": {
"Deved\\DisableRegistration\\": ""
}
}
}
16 changes: 16 additions & 0 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?xml version="1.0"?>
<!--
~ Copyright (c) 2016 Salvatore Guarino. All rights reserved.
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:module:Magento_Config:etc/system_file.xsd">
<system>
<section id="customer">
<group id="create_account">
<field id="disable_customer_registration" translate="label comment" type="select" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Disable frontend customer registration</label>
<source_model>Magento\Config\Model\Config\Source\Yesno</source_model>
</field>
</group>
</section>
</system>
</config>
6 changes: 6 additions & 0 deletions etc/di.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?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="Deved_DisableRegistration::after" type="Deved\DisableRegistration\Plugin\RegistrationPlugin"/>
</type>
</config>
8 changes: 8 additions & 0 deletions etc/module.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?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="Deved_DisableRegistration" setup_version="2.0.0">
<sequence>
<module name="Magento_Customer"/>
</sequence>
</module>
</config>
6 changes: 6 additions & 0 deletions registration.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?php
\Magento\Framework\Component\ComponentRegistrar::register(
\Magento\Framework\Component\ComponentRegistrar::MODULE,
'Deved_DisableRegistration',
__DIR__
);

0 comments on commit 1af626a

Please sign in to comment.