Skip to main content

Permissions

Default permissions

Permission defaults can be overwritten within the file humhub/config/common.php (Advanced Configuration) by means of the defaultPermissions params array.

The following example overwrites the default permission of humhub\modules\mymodule\permissions\MyPermission for the given groups.

return [
'params' => [
'defaultPermissions' => [
'humhub\modules\mymodule\permissions\MyPermission' => [
\humhub\modules\user\models\User::USERGROUP_SELF => \humhub\libs\BasePermission::STATE_ALLOW,
\humhub\modules\user\models\User::USERGROUP_USER => \humhub\libs\BasePermission::STATE_ALLOW,
\humhub\modules\user\models\User::USERGROUP_FRIEND => \humhub\libs\BasePermission::STATE_ALLOW,
\humhub\modules\user\models\User::USERGROUP_GUEST => \humhub\libs\BasePermission::STATE_ALLOW,
],
]
]
]

User Groups

Available user groups in profile context:

GroupDescription
\humhub\modules\user\models\User::USERGROUP_SELFThe user himself
\humhub\modules\user\models\User::USERGROUP_USERAny registered user
\humhub\modules\user\models\User::USERGROUP_FRIENDA befriended user
\humhub\modules\user\models\User::USERGROUP_GUESTAny user, even unauthenticated if available

Available user groups in space context:

GroupDescription
\humhub\modules\space\models\Space::USERGROUP_OWNERThe owner of the space
\humhub\modules\space\models\Space::USERGROUP_ADMINAn administrator of the space
\humhub\modules\space\models\Space::USERGROUP_MODERATORA moderator of the space
\humhub\modules\space\models\Space::USERGROUP_MEMBERA member of the space
\humhub\modules\space\models\Space::USERGROUP_USERAny registered user
\humhub\modules\space\models\Space::USERGROUP_GUESTAny user, even unauthenticated if available

Core Permissions

Global context

ClassDescription
\humhub\modules\admin\permissions\ManageGroupsManage user groups
\humhub\modules\admin\permissions\ManageModulesManage installed modules
\humhub\modules\admin\permissions\ManageSettingsManage administrative settings
\humhub\modules\admin\permissions\ManageSpacesManage spaces
\humhub\modules\admin\permissions\ManageUsersManage users
\humhub\modules\admin\permissions\SeeAdminInformationAccess to administrative informations
\humhub\modules\space\permissions\CreatePrivateSpaceThe user is allowed to create private spaces.
\humhub\modules\space\permissions\CreatePublicSpaceThe user is allowed to create public spaces.

Content Container (Space or Profile) context

ClassDescription
\humhub\modules\user\permissions\ViewAboutPageAccess to the profile about page. (User profile only!)
\humhub\modules\comment\permissions\CreateCommentAllowed to create new comments.
\humhub\modules\post\permissions\CreatePostAllowed to create new posts.
\humhub\modules\topic\permissions\AddTopicAllowed to create new topics.
\humhub\modules\topic\permissions\ManageTopicsAllowed to manage existing topics.

Examples

Allow non friend users to access the "About" page.

<?php
//...
return [
'params' => [
'defaultPermissions' => [
'humhub\modules\user\permissions\ViewAboutPage' => [
\humhub\modules\user\models\User::USERGROUP_USER => \humhub\libs\BasePermission::STATE_ALLOW,
],
]
]
];