Create customer attribute Is blocked? (can only edit from admin,setby default NO) http://prntscr.com/n2yn78 , http://prntscr.com/n2yq5r
then use observer event after login check it's value
if it is blocked youcan logged out him and redirect to any page
Use customer_login event observer for customer login action
1) Create events.xml
app/code/Vendor/Module/etc/events.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="customer_login">
<observer name="customer_login_observer" instance="Vendor\Module\Observer\CustomerLogin" />
</event>
</config>
2) Now create observer CustomerLogin.php
app/code/Vendor/Module/Observer/CustomerLogin.php
<?php
namespace Vendor\Module\Observer;
use Magento\Framework\Event\ObserverInterface;
class CustomerLogin implements ObserverInterface
{
/**
* @var \Magento\Framework\App\ResponseFactory
*/
private $responseFactory;
/**
* @var \Magento\Framework\UrlInterface
*/
private $url;
private $customerSession;
private $messageManager;
public function __construct(
\Magento\Framework\App\ResponseFactory $responseFactory,
\Magento\Framework\UrlInterface $url,
\Magento\Customer\Model\Session $customerSession,
\Magento\Framework\Message\ManagerInterface $messageManager
) {
$this->responseFactory = $responseFactory;
$this->url = $url;
$this->customerSession= $customerSession;
$this->messageManager = $messageManager;
}
public function execute(\Magento\Framework\Event\Observer $observer)
{
$customer = $observer->getEvent()->getCustomer();
if($customer->getIsBlocked()){
$customerSession->logout();
$this->messageManager->addErrorMessage(__('You are Blocked'));
$redirectionUrl = $this->url->getUrl('set-your-redirect-url');
$this->responseFactory->create()->setRedirect($redirectionUrl)->sendResponse();
return $this;
}
}
}