Simple Machines Community Forum

Customizing SMF => SMF Coding Discussion => Topic started by: webou on June 09, 2010, 05:16:17 PM

Title: Adding a link in profile box - only viewable by admin + a group
Post by: webou on June 09, 2010, 05:16:17 PM
Hello,

I am modifying /Themes/default/Display.template.php because I want to add a link there, only for admins and mods.

So I am using this code :if($context['allow_admin'] || in_array(2, $user_info['groups']))

This makes the link viewable by the admins, but not by the mods (group 2).
This code works on another part of the website (with SSI.php).

I don't really know what's wrong.

Thanks,

Mike
Title: Re: Adding a link in profile box - only viewable by admin + a group
Post by: Arantor on June 09, 2010, 05:22:38 PM
Do you get any errors?
Title: Re: Adding a link in profile box - only viewable by admin + a group
Post by: webou on June 09, 2010, 05:25:48 PM
No, not any.

I tried to look for the $user_info array :
echo '<pre>';
print_r($user_info);
echo '</pre>';


But it gives no output, so the array would not exist when displaying a topic ?
Title: Re: Adding a link in profile box - only viewable by admin + a group
Post by: Arantor on June 09, 2010, 05:29:06 PM
No, that means it's not in scope. Add $user_info to the list of global variables at the start of the function.
Title: Re: Adding a link in profile box - only viewable by admin + a group
Post by: webou on June 09, 2010, 05:34:50 PM
Excellent that did it ! Thank you for your speed and accuracy :)