Get the permission model for the application.
public static permissionModel ( ) : PermissionModel | ||
return | PermissionModel |
$permissionModel = Gdn::permissionModel(); if ($permissionModel->checkPermission('Vanilla.Community.AddDiscussion')) { // do something } else { // show error message }
$permissionModel = Gdn::permissionModel(); $isAdmin = $permissionModel->checkPermission('Garden.Settings.Manage');In this example, we use the `checkPermission` method to check if the user has permission to manage site settings. The result of the check is then stored in the `$isAdmin` variable. We could use this variable to conditionally show certain admin-only features or sections of the site. Overall, the Gdn permissionModel is a powerful tool for managing user permissions in a Vanilla forum or custom web application built on the Vanilla framework. Its functions are essential in maintaining security and managing user roles.
public static permissionModel ( ) : PermissionModel | ||
return | PermissionModel |