The forum of the forums
Welcome to the Official Support Forum of Forumotion!

To take full advantage of everything offered by our forum, please log in if you are already a member, or join our community if you've not yet.



Create a free forum like this one.

Which are the userlevels?

View previous topic View next topic Go down

Solved Which are the userlevels?

Post by Van-Helsing on October 13th 2014, 12:24 am

Hello,
Which are the userlevels which can we use in javascripts?


Last edited by Black-Shadow on October 13th 2014, 1:51 am; edited 1 time in total

Van-Helsing
Hyperactive

Male Posts : 2222
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Which are the userlevels?

Post by Ange Tuteur on October 13th 2014, 12:35 am

Hello Black-Shadow,

You can access user level by typing :
Code:
_userdata["user_level"]

// or

_userdata.user_level

The levels available are :
0 = Guest / Member
1 = Administrator
2 = Moderator

You can't access _userdata right away, so you must wait for the document to be ready. Type your code inside :
Code:
$(function() {
 //code to be executed
});

Then all you need to do is write your conditions :
Code:
$(function() {
 if (_userdata.user_level === 0) alert('You\'re a Member !');
 if (_userdata.user_level === 1) alert('You\'re an Administrator !');
 if (_userdata.user_level === 2) alert('You\'re a Moderator !');
});

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Which are the userlevels?

Post by Van-Helsing on October 13th 2014, 12:43 am

Hello Ange,
I have found this tutorial http://www.fmcodes.com/t1028-different-permissions-for-topics-in-the-same-forum but it has more than 3 userlevels in description. Is it correct?

Van-Helsing
Hyperactive

Male Posts : 2222
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Which are the userlevels?

Post by Ange Tuteur on October 13th 2014, 12:55 am

I can't see the post, but to my knowledge, the levels I mentioned above are the ones that occur while logged in as an Admin, Mod, or member / guest.

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Which are the userlevels?

Post by Van-Helsing on October 13th 2014, 12:58 am

Here is the code for PunBB

Code:

$(document).ready(function(){
    if (typeof _userdata === "undefined") return;
    if (_userdata["session_logged_in"] = '1' && jQuery('img').length > '1' && _userdata["user_level"] != 'STATUS ID') {

$('img[src="ICONLINK"]').closest('tr').remove();

  };

});

and the explanation is:

Change ICONLINK with the link of the subject icon
Change STATUS ID with


1 if the topics with that icon must be removed for non admins (mod, mebers and guests)
2 if the topics with that icon must be removed for non moderators (in general, not of that forum) (admins, members, guests)
3 if the topics with that icon must be removed for non members (admins, mods, guests)
4 if the topics with that icon must be removed for non guests (admins, members, mods)

Van-Helsing
Hyperactive

Male Posts : 2222
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Which are the userlevels?

Post by Ange Tuteur on October 13th 2014, 1:02 am

Yes, that should work fine. The modifier in use is "!=" which is literally : "Not equal to."

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Which are the userlevels?

Post by Van-Helsing on October 13th 2014, 1:06 am

Which number of userlevel must I give to STATUS ID to make the topic only visible for admin and mods?

Van-Helsing
Hyperactive

Male Posts : 2222
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Which are the userlevels?

Post by Ange Tuteur on October 13th 2014, 1:18 am

I would write this :
Code:
$(function() { if (_userdata.user_level == 0) $('img[src="ICONLINK"]').closest('tr').remove(); });

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

Solved Re: Which are the userlevels?

Post by Van-Helsing on October 13th 2014, 1:47 am

I have adapt the code into this code:

Code:

$(document).ready(function(){
if (typeof _userdata === "undefined") return;
if (_userdata["session_logged_in"] = '1' && jQuery('img').length > '1' && _userdata["user_level"] != '1' && _userdata["user_level"] != '2') {

$('img[src="IMAGE URL"]').closest('tr').remove();
};
});
and its working fine.

Thank you very much Ange.
Problem is solved.

Best Regards,
Black-Shadow

Van-Helsing
Hyperactive

Male Posts : 2222
Reputation : 82
Language : English, Greek

http://helpgr.forumgreek.com/

Back to top Go down

Solved Re: Which are the userlevels?

Post by Ange Tuteur on October 13th 2014, 2:08 am

You're welcome ^^

Topic archived

Ange Tuteur
Forumaster

Male Posts : 13028
Reputation : 2704
Language : EN10, FR5
Location : Pennsylvania

http://fmdesign.forumotion.com

Back to top Go down

View previous topic View next topic Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum