🔥 Just Launched! Werra Premium Template for HyväSee it in Action

How To Remove Insert Variable & Insert Widget From WYSIWYG Editor In Magento 2

By Sanjay JethvaUpdated on May 22, 2025 2 min read

WYSIWYG editor in Magento 2 is an HTML editor that offers “what you see is what you get”  functionality. It makes the task of adding, editing and formatting the content easier.

However, sometimes offering this editor gives unnecessary rights and features by allowing them to insert the variable and widget.

For example, the Magento marketplace has multiple users and vendors who can use the WYSIWYG editor from the admin panel. The super admin would not want them to use all the widgets but only allow designing with the editor. In such cases, one can use the below solution.

The default WYSIWYG editor in the Magento 2 is as shown here:

Default WYSIWYG Editor - Meetanshi

After implementing the below code, the WYSIWYG editor is as shown here:

Custom editor - Meetanshi

Method to remove add variable & add widget from WYSIWYG editor in Magento 2:

1. Add below code in the system.xml file

<field id="description" translate="label comment" type="editor" sortOrder="20" showInDefault="1"
                       showInWebsite="1" showInStore="1">
    <label>Description </label>
    <frontend_model>Vendor\Extension\Block\Adminhtml\Editor</frontend_model>
</field>

2. Create new file Editor.php at Vendor\Extension\Block\Adminhtml folder

<?php
 
namespace Vendor\Extension\Block\Adminhtml;
 
use Magento\Backend\Block\Template\Context;
use Magento\Cms\Model\Wysiwyg\Config as WysiwygConfig;
 
class Editor extends \Magento\Config\Block\System\Config\Form\Field
{
    public function __construct(
        Context $context,
        WysiwygConfig $wysiwygConfig,
        array $data = []
    )
    {
        $this->_wysiwygConfig = $wysiwygConfig;
        parent::__construct($context, $data);
    }
 
    protected function _getElementHtml(\Magento\Framework\Data\Form\Element\AbstractElement $element)
    {
        $element->setWysiwyg(true);
        $confgiData = $this->wysiwygConfig->getConfig($element);
        $confgiData->setplugins([]);
        $confgiData->setadd_variables(0);
        $confgiData->setadd_widgets(0);

        $element->setConfig($confgiData);
        return parent::_getElementHtml($element);
    }
}

That’s it.

Please share the solution with the Magento community via social media.

Thank you.

Sanjay Jethva Full Image
Article bySanjay Jethva

Sanjay is the co-founder and CTO of Meetanshi with hands-on expertise with Magento since 2011. He specializes in complex development, integrations, extensions, and customizations. Sanjay is one the top 50 contributor to the Magento community and is recognized by Adobe. His passion for Magento 2 and Shopify solutions has made him a trusted source for businesses seeking to optimize their online stores. He loves sharing technical solutions related to Magento 2 & Shopify.