Simple Machines Community Forum

SMF Support => SMF 2.0.x Support => Topic started by: a454nova on November 02, 2008, 11:55:52 PM

Title: Buttons
Post by: a454nova on November 02, 2008, 11:55:52 PM
How do you control when the buttons show?  Like the admin button, I want to make a button that only shows for a certain member group.
Title: Re: Buttons
Post by: Nathaniel on November 03, 2008, 01:05:21 AM
You will need to edit the "setupMenuContext()" function from your Subs.php file.

You can change the 'show' value for each button (see below). You will have to change the 'true' value to the condition that you want to check. If they have to be admin then use 'allowedTo('admin_forum')'
'show' => true,

The post below covers how to add a new button to your menu:
http://www.simplemachines.org/community/index.php?topic=256570.msg1667966#msg1667966
Title: Re: Buttons
Post by: a454nova on November 03, 2008, 01:38:56 AM
Still doesn't make sense. I know how to add the button, I can use the line from admin, guest, or calender so that it only shows with admin, logged out, logged in, or with calender. I need to know how or pointed in a better direction to make it so that the new button I just made, lets say button "MAIL". I only want the button to show up for the Member Group I made called "VIP". If one of my users is a VIP then they can see and have access to the "MAIL" button. Is it easy or more trouble than its worth?
Title: Re: Buttons
Post by: Nathaniel on November 03, 2008, 02:32:59 AM
That should be relatively easy to do.

Use this code for your 'show part':
'show' => in_array({id}, $user_info['groups']),

Replace '{id}' with the ID of the group that you want to be able to see that button. You can find it by going to the 'Modify' page for that membergroup, the id will in the the url of that page, 'group=id'.

And end result might look like this:
         'mail' => array(
            'title' => 'MAIL,
            'href' => 'http://www.domain.com',
            'show' => in_array(1, $user_info['groups']),
            'sub_buttons' => array(
            ),
         ),

Title: Re: Buttons
Post by: a454nova on November 03, 2008, 04:28:37 AM
I'll try that here when my eyes are not so heavy. : ) If it works then mad props and thank you tons LHVWB!




NOTE: I got some rest and tried it and it worked....  YOU DA MAN!!

THANKS!