Hiding the Help Button Part 3

Hiding things in the MODX Manager from specific user groups.

By Bob Ray  |  May 12, 2026  |  4 min read
Hiding the Help Button Part 3

In the previous article, we used a plugin to hide the "Help" button that appears on the panel for creating and updating various MODX objects like Resources, Elements, System Settings, and Media Sources, from everyone. In this article we'll look at a way to select which users the button is hidden from based on the User Groups they belong to.

The Old Plugin

This is the plugin from the previous article (see the previous article for the steps to create the plugin):

/* HideHelp Plugin */
$css = '
    <style>
        #modx-abtn-help {
            display: none !important;
        }
    </style>
';

$modx->regClientCSS($css);

return '';

The New Plugin

It takes a very small modification of the plugin to selectively hide the Help button based on the current user's User Group. The isMember() method can be used to tell if a user is a member of a given User Group (or multiple User Groups). We just need to wrap the code that hides the button in an if statement. This version of the plugin will hide the Help button from anyone who is not a member of the Administrator user group:

/* HideHelp Plugin */
if (! $modx->user->isMember('Administrator') ) {
    $css = '
    <style>
        #modx-abtn-help {
            display: none !important;
        }
    </style>
    ';

    $modx->regClientCSS($css);
}

return '';

The exclamation point in the if statement above can be read as "not", so the code inside the outer curly braces will only execute for users who are not members of the Administrator group. Here is another way to do the same thing:

/* HideHelp Plugin */
if ($modx->user->isMember('Administrator') ) {
    return '';
}

$css = '
<style>
    #modx-abtn-help {
        display: none !important;
    }
</style>
';

$modx->regClientCSS($css);

return '';

In this second version, if the user is a member of the Administrator group, the plugin returns without doing anything at all. For non-Administrators, it continues on and executes the code that hides the button. It's a common principle to have only one return statement, which appears at the end of your code. It makes the code cleaner and easier to maintain. I violate this principle occasionally if it will speed things up, though in this case there would be no significant time difference between the two versions, so I would probably use the first one.

While we're on the subject of coding practices, here's an example of something I see often that you should avoid, if possible:

/* HideHelp Plugin */

$css = '
<style>
    #modx-abtn-help {
        display: none !important;
    }
</style>
';

if (! $modx->user->isMember('Administrator') ) {
    $modx->regClientCSS($css);
}

return '';

Do you see what's wrong with this code? It would work, and it seems logical that you would only inject the CSS if the user was not an Administrator. But why execute the code at the top of the plugin to set up the content of the $css variable if it's never going to be used. It's just wasting processor time and memory (in this case, only a tiny bit — but why waste anything?). If you have an if statement that tests for a condition under which some operations will be performed, put everything that will be performed based on the results inside the if statement.

This is not a great example, because in later versions of PHP, the PHP parser will likely create the $css variable before the code even executes. Still, the principle is a good one to keep in mind. Try to avoid creating code that will execute even if it won't be needed unless certain conditions apply. Test the conditions above the code that may not be necessary.

Test for Multiple Groups

The isMember() method can take an array of User Group names as its argument. This version will hide the button from everyone who is not a member of either the Administrator or Editor Groups:

/* HideHelp Plugin */
$AllowedGroups = array(
    'Administrator',
    'Editor',
);

if (! $modx->user->isMember($allowedGroups)) {
$css = '
<style>
    #modx-abtn-help {
        display: none !important;
    }
</style>
';

$modx->regClientCSS($css);
}

return '';

For completeness, I should mention that isMember() takes a second argument that is seldom used. If set to true, it tests whether the user belongs to all groups in the array. If you wanted to show the button only to people who are both Administrators and Editors, you'd do this:

/* HideHelp Plugin */
$AllowedGroups = array(
    'Administrator',
    'Editor',
);

if (! $modx->user->isMember($allowedGroups, true)) {
$css = '
<style>
    #modx-abtn-help {
        display: none !important;
    }
</style>
';

$modx->regClientCSS($css);
}

return '';

I've never needed this feature, but someday, you may find a use for it.

Coming Up

In my next article, we'll see how to hide some other page elements using the same CSS injection technique we used to hide the Help button.


About Bob Ray

Bob Ray is the author of the MODX: The Official Guide and dozens of MODX Extras including QuickEmail, NewsPublisher, SiteCheck, GoRevo, Personalize, EZfaq, MyComponent and many more. His website is Bob’s Guides. It not only includes a plethora of MODX tutorials but there are some really great bread recipes there, as well.

Learn more about Bob Ray.