Fixed Dropdown button in editor


Well-known member
Affected version
If you add a drop-down menu in the bb code editor and assign bbcodes there, assign viewing rights. And if the user does not have rights for these bb codes, then the drop-down button will still hang. It would be correct if the list for the user is empty, then do not display this drop-down menu in the editor.
We already have code to handle this in the cases where we remove buttons.

For example, if you consider the rich text editor when used to edit signatures, we do remove some buttons based on permissions there.

My attempted reproduction case was to set all permissions to never except "Allow images" and "Allow links".


I then modified the editor button configuration so that "Insert image" and "Insert link" were in a drop down, and I included only that drop down in the editor.



With the permissions as configured above:


With the permissions denying access to links and images:


It seems as though we correctly remove a dropdown that is empty.

So with that in mind, you need to adjust your code so the same thing happens.
@Chris D, This works for Custom BB codes. I will give an example of reproduction in the Media Gallery.
1) Create dropdown
2) check event listener on gallery:
public static function templaterTemplatePreRenderPublicEditor(\XF\Template\Templater $templater, &$type, &$template, array &$params)
        if (isset($params['customIcons']['gallery']))
            if (!self::visitor()->canViewMedia())
Well going in permission
3) Add in editor:
4) going in public part:
5) Trying give permission to view media
6) Check in public part
And it's work correctly and we can use dropdown menu. And the dropdown is not hiding
In that case, it is what I said, but it's actually XFMG that's wrong.

The code in XFMG (and presumably your own) should be similar to:

public static function templaterTemplatePreRenderPublicEditor(\XF\Template\Templater $templater, &$type, &$template, array &$params)
   if (!self::visitor()->canViewMedia())
      $params['removeButtons'][] = 'xfCustom_gallery';
Thank you for reporting this issue, it has now been resolved. We are aiming to include any changes that have been made in a future XFMG release (2.1.8).

Change log:
When there is no permission to view media, ensure the custom BB code gallery button is removed appropriately.
There may be a delay before changes are rolled out to the XenForo Community.
Top Bottom