by Ange Tuteur April 28th 2015, 9:01 pm
Hi
@Black-Shadow,
The code looked a bit messy on the ending parentheses and brackets. I cleaned it up for you :
- Code:
$(function(){
if (!_userdata.user_level) $('#elem1').hide();
});
If it's still not hidden, check the attributes of the element you're trying to hide to see if you have to correct ID.
You were hiding this for non-staff, correct ? I'll show you a few simplified methods for checking the user state. See the comments for the purpose :
- Code:
if (!_userdata.user_level) console.log('MEMBER'); // if the member is NOT staff e.g. user level == 0
if (_userdata.user_level) console.log('STAFF'); if the member IS staff e.g. user level 1 or 2
// after this you can check the values using comparison symbols.
if (_userdata.user_level == 1) console.log('ADMIN'); // user level 1 == admin
if (_userdata.user_level == 2) console.log('MODERATOR'); // user level 2 == mod
You'll see the first two conditions I used no comparison symbols. It's simple boolean math 0 == false and anything above 0 is true. More simply, the exclamation point (!) inverts our condition performing a check for false values.