• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

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

#1
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.
 

arcaneex

Active member
#3
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.
 

Jake Bunce

XenForo moderator
Staff member
#6
Code example from the forum controller:

XenForo_ControllerPublic_Forum

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)
					);
				}
			}
		}