In a MediaWiki-based non-communal website there are some HTML elements that should be presented only for logged-in-users (an administration menu or some of its links).

Usually if I want to hide something for a certain group of users like anonymous users I browse into the website when logged-out, and then take a <body> CSS ID or Class like #anonymous-user to create some condition like this:

#anonymous-user .administration-menu {display: none}

I tried to search for a <body> CSS ID or Class that I could utilize to hide things for anonymous users in MediaWiki but found none.

How could I create one myself?

  • All display:none is doing is hiding a section of a page if a user is using your stylesheet, which they can turn off. If there are links only for admins that is a very bad way of operating. Instead you should have a server variable set when a user is logged in, test for that, and only if it's set then create in PHP the section containing the links. MediaWiki tests for logged in users with if ( $user->isLoggedIn() ) {, see eg user.php.
    – pbhj
    Commented Jun 17, 2019 at 21:46

1 Answer 1


You will have to adjust the user/group permissions behind the scenes. Here is the guide the default user and group permissions that are installed on the stock API.

MediaWiki Help:User rights and groups

You may have to work in reverse with the stock permissions by hiding / restricting features to the “all” group then allowing the features to the “users” and “administrators” list.

Your Answer

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