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

Discussion in 'XenForo Development Discussions' started by Fuhrmann, Oct 9, 2011.

  1. Fuhrmann

    Fuhrmann Well-Known Member

    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}">

  2. ragtek

    ragtek Guest

    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:
  3. Fuhrmann

    Fuhrmann Well-Known Member

    Yeeesss. Thanks ragtek!!;)

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

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

    ragtek Guest

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

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

  5. ragtek

    ragtek Guest

    OR MUCH better

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

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

    Fuhrmann Well-Known Member

    Reaally good!!
    I will do that!

    Thanks again!:ROFLMAO:

Share This Page