Forum:How to make a section only visible to anonymous users?

Hello! I need to put a new div section with a specific message on the main page of Mass Effect Answers wiki. The problem is, I need it to only show itself to anonymous users. Can anyone say, is this possible, and how to do it? Mitranim 08:54, August 1, 2011 (UTC)


 * You could make the div hide as default with css, and then use js to display it if the user rights match those of an anon. I think this code should work:
 * Tag the div with a class of 'anonmessage'.
 * Add the following code to wikia.css:

.anonmessage { display: none }
 * Add the following code to wikia.js:

function AnonMessage { if(window.wgUserGroups && (wgUserGroups.indexOf("null")) != -1) { $('.anonmessage').css({"display": 'inline'}); } } $(AnonMessage);




 * Close, but wgUserGroups isn't a string, so that'll break. You'll want this:

 function AnonMessage { if(wgUserGroups == null) { $('.anonmessage').css('display', 'inline'); } } addOnloadHook(AnonMessage)
 * It may have problems displaying properly because it's inline, but that can be fixed by changing it to block.


 * It works! Cool … — Spike Toronto  17:47, August 1, 2011 (UTC)
 * Can also be modified for showing sysop only messages, or autoconfirmed only messages, or even weird stuff like emailconfirmed only messages. It's also worth noting just for future reference that hiding messages from users who aren't in certain user groups has been discussed before, and it's not such a bad thing, considering anyone can view the source of the page and read what's inside the div.


 * Tagging FAQ. -- Fandyllic (talk &middot; contr) 1 Aug 2011 11:25 AM Pacific