Chen
05 Mar 2002, 18:46
Frequently, you want parts of your hack to only be accessible by moderators and admins.
To do so, you use this if-block:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
And if you want to give another usergroup access for that action, you need to add even another OR to that statement!
A much more elegant solution would be to use in_array():
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
You can even declare an array, let's say $allowedgroups, that can be used throughout the code:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
This is also not only useable when checking usergroups! Let's say you have feature you only want visible on forums 4, 6, 18 and 65:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Not really a tip nor a trick, but I'm a bit bored so... :)
To do so, you use this if-block:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
And if you want to give another usergroup access for that action, you need to add even another OR to that statement!
A much more elegant solution would be to use in_array():
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
You can even declare an array, let's say $allowedgroups, that can be used throughout the code:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
This is also not only useable when checking usergroups! Let's say you have feature you only want visible on forums 4, 6, 18 and 65:
Code:
---------------
Code is only visible to licensed users, and only when logged into the forums.
---------------
Not really a tip nor a trick, but I'm a bit bored so... :)