Getting users permissions/checking if a user can view a forum.


I don't see this being done anywhere, I made a page and dumped all the variables available to it however outside of the session data having the user id I've found nothing.


Well-known member
It can be done, but the permission system is a little confusing to make this a reality.


Active member
Well you can use a conditional to check if a user in the usergroup which can view a forum.
<xen:if is="{xen:helper ismemberof, $visitor, x}">
Replace X with the User group ID.


Active member
No idea, sorry.
EDIT: It may be possible using the database, using the same if condition. But to be honest, not sure how.

Jake Bunce

XenForo moderator
Staff member
Code example from the forum controller:


Rich (BB code):
		if ($forumIds)
			/* @var $forumModel XenForo_Model_Forum */
			$forumModel = XenForo_Model::create('XenForo_Model_Forum');

			$visitor = XenForo_Visitor::getInstance();
			$permissionCombinationId = $visitor['permission_combination_id'];

			$forums = $forumModel->getForumsByIds($forumIds, array(
				'permissionCombinationId' => $permissionCombinationId
			foreach ($forums AS $forum)
				$visitor->setNodePermissions($forum['node_id'], $forum['node_permission_cache']);
				if ($forumModel->canViewForum($forum))
					$forumData[$forum['node_id']] = array(
						'title' => $forum['title'],
						'url' => XenForo_Link::buildPublicLink('forums', $forum)