Magento 2 – Remove Button from Customer Admin Form

adminhtmlmagento2

I want to remove the Create Order button from the admin customer edit form and I don't know how to do this via a plugin or an event.

The button is added from Magento\Customer\Block\Adminhtml\Edit::_construct and I cannot write a plugin for a protected method.
Is there an event, or a public method that is called after the buttons are added and before the layout is rendered that I can use?

Best Answer

After test I think it work with Magento\Customer\Block\Adminhtml\Edit\OrderButton and not Magento\Customer\Block\Adminhtml\Edit it has public function:

public function getButtonData()
{
    $customerId = $this->getCustomerId();
    $data = [];
    if ($customerId && $this->authorization->isAllowed('Magento_Sales::create')) {
        $data = [
            'label' => __('Create Order'),
            'on_click' => sprintf("location.href = '%s';", $this->getCreateOrderUrl()),
            'class' => 'add',
            'sort_order' => 40,
        ];
    }
    return $data;
}

you can use plugin is public function