Jump to content

Topic on Project:Support desk

How to hide Sidebar_Menu links for anonymous users?

11
49.230.97.196 (talkcontribs)

In MediaWiki 1.32.0, I have added, just for the sake of comfortability, some admin-oriented links to the Sidebar menu, but these links appear to anonymous users.

How could I hide these specific links for anonymous users (the rest of the Sidebar menu will look the same for everyone)?<br>I thought about selecting a class like ".not-logged-in" but found no such class.

DannyS712 (talkcontribs)

My guess is that you would need to hide them by id in common.js, and then reshow them using, eg, group-autoconfirmed.js

Kghbln (talkcontribs)

Have a look at the UserFunctions extension. This is how I do this by checking if a user is anonymous and if yes, do not show the link.

AhmadF.Cheema (talkcontribs)
49.230.62.64 (talkcontribs)

I just want to add classes from the menu-edit-page by myself (these will be added to those who are machine-created and already exist).

49.230.62.64 (talkcontribs)

Thank you all. @DannyS712 your suggestion seems best to me.

DannyS712 (talkcontribs)

No problem. Do you want me to right up some css for you?

49.230.62.64 (talkcontribs)

@DannyS712 no, but thanks for your generosity. I don't use any CSS here; just JS. What CSS would you use?

DannyS712 (talkcontribs)

It’s easier to hide the elements with plain css, rather than injecting the css with js (assuming that is what you were going to do. If not, then what? I’m curious how else it could be done)

49.230.62.64 (talkcontribs)

@DannyS712 in this case I do it by hiding and unhiding from JS; if there way a body class for anonymous surfing, I would use it to hide the elements only for anonymous users, but there isn't such body class as of MediaWiki 1.32.0 so I must hide and selectively unhide with JavaScript as you suggested.

Reply to "How to hide Sidebar_Menu links for anonymous users?"