How to check permissions

If you are writing custom code for SMF, such as a mod or a website integration with SSI.php, you can easily check for standard or custom permissions. The membergroup and board permissions are available through a few simple functions, and it works for guests too.

There are two ways to check for permissions; you can check only whether someone has a permission, or you can check the permission and then display an error if they don't.

Examples:

 

Checking Board Permissions
When inside a board there is no difference between checking board or membergroup permissions. Board permissions are however only given to users when they are inside a board, so testing for board permissions outside of a board or topic will generally return false. Local permissions also complicate the system: if users have a certain board permission in one board but not in another because of local permissions, they will only have that permission in one board. SMF will only tell you the permissions in the current board and not reveal permissions of other boards. If however you want to check board permissions when not inside a board or topic, or you want to check permissions of a different board, that is possible as the following example shows:

 Through a different function you can check which boards a user has a permission on:

