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

Adding new permissions to visitor

Fuhrmann

Well-known member
#1
Ok, wanna insert a new tab in the Visitor Navigation Tab.

Using the hook navigation_visitor_tab_links2 works well.

But i want to use a conditional, for my addon: If user canAddSomething he can see the tab.

How can i add this permission to the user? So i can use:

<xen:if is="{$canAddSomething}">

Thanks!
 
R

ragtek

Guest
#2
You need to create the new permission!

ACP => search for Permission Definitions (i love the new search and don't use the menu, so don't know where it is;) )=> new permission;)

and to test it you can use:
PHP:
 XenForo_Visitor::getInstance()->hasPermission('group', 'perm_name')
 

Fuhrmann

Well-known member
#3
You need to create the new permission!

ACP => search for Permission Definitions (i love the new search and don't use the menu, so don't know where it is;) )=> new permission;)

and to test it you can use:
PHP:
XenForo_Visitor::getInstance()->hasPermission('group', 'perm_name')
Yeeesss. Thanks ragtek!!;)

But now, this: i wanna use this permission in my template.
So i have a template with this:

Code:
<xen:if is="{$canDoSomething}">
<li>
<a class="{xen:if "{$selectedKey} == 'alerts/bookmarks'", 'secondaryContent', 'primaryContent'}" href="{xen:link account/bookmarks}">{xen:phrase your_bookmarks}</a>
</li>
</xen:if>
The template use the hook navigation_visitor_tab_links2.
 
R

ragtek

Guest
#4
You need to check this on php side and send the variable to you template

$canDoSomething = XenForo_Visitor::getInstance()->hasPermission('group', 'perm_na...


 
R

ragtek

Guest
#5
OR MUCH better

don't check this in the template! include the template only if the user have permissions;)
e.g. =>
PHP:
 if ($name == 'navigation_visitor_tab_links1') {
            if (Ragtek_Invite_Helper::perm('canUse')) {

                $contents .= $template->create('ragtek_invite_visitortab');
            }
        }
 

Fuhrmann

Well-known member
#6
OR MUCH better

don't check this in the template! include the template only if the user have permissions;)
e.g. =>
PHP:
if ($name == 'navigation_visitor_tab_links1') {
            if (Ragtek_Invite_Helper::perm('canUse')) {

                $contents .= $template->create('ragtek_invite_visitortab');
            }
        }
Reaally good!!
I will do that!

Thanks again!:ROFLMAO: