In Magento from admin panel we can delete customer and ca do mass delete of customers. Is there any way to run an observer before deleting customer we can get the customer id ?

2 Answers 2


You can use the around plugin here.


<?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\ResourceModel\CustomerRepository">
        <plugin name="customer_delete_action" type="Vendor\Module\Plugin\DeleteCustomer" />




namespace Vendor\Module\Plugin;

class DeleteCustomer
    public function aroundDeleteById(
        \Magento\Customer\Model\ResourceModel\CustomerRepository $subject,
        \Closure $proceed,
    ) {
        // You can add your logic here
        if ($customerId == 10) {
            // Play here

        // It will proceed ahead with the default delete function        
        $result = $proceed($customerId);

        return $result;

You can try using event customer_delete_before
And in the observer, you can get the object data using

$object = $observer->getData('object');

And you can get the customer id using


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.