Author Topic: Hiding Shop Button for members of a certain membergroup  (Read 4625 times)

Abangyarudo

  • Guest
Hiding Shop Button for members of a certain membergroup
« on: September 01, 2007, 06:44:51 am »
Hi I was wondering cause I don't know how advanced this would be but I'd like to hide the shop button for members of certain membergroups. I run a role playing forum and am planning to use the smf shop to be able to let characters buy items and equipment for their characters so groups like the player membergroup and staff membergroups would not need the shop button. Thanks in Advance.

Offline Daniel15

Re: Hiding Shop Button for members of a certain membergroup
« Reply #1 on: September 01, 2007, 10:41:26 am »
Are they primary membergroups, or aditional membergroups?

In Themes/<your theme name>/index.template.php, find your shop button code. It will look a little like this:
Code: [Select]
//Begin SMFShop code
echo ($current_action == 'shop' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'shop' ? 'active_back' : 'back' , '">
<a href="', $scripturl, '?action=shop">Shop</a>
</td>' , $current_action == 'shop' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
//END SMFShop code
(search for ?action=shop to find it)

Right above the "echo" bit (in this case, it's directly below the // Begin SMFShop code line), add this:
Code: [Select]
global $user_info;
// Groups to hide the shop button from.
$shop_disabled_groups = array(1, 2, 3);
// Only show the button if they're not in any of these groups.
if (!in_array($shop_disabled_groups, $user_info['groups']))
Change the "1" to the ID of the group you want to hide the button from. In the "Membergroups" section of the admin panel, clicking the "Modify" link will show the ID in your browser's address bar (eg. ?action=membergroups;sa=edit;group=4).

Abangyarudo

  • Guest
Re: Hiding Shop Button for members of a certain membergroup
« Reply #2 on: September 02, 2007, 07:10:22 am »
thank you

Offline Dark_Zero

Re: [SOLVED] Hiding Shop Button for members of a certain membergroup
« Reply #3 on: September 02, 2007, 12:38:57 pm »
just for future reference; what about multiple groups?

Abangyarudo

  • Guest
Re: [SOLVED] Hiding Shop Button for members of a certain membergroup
« Reply #4 on: September 02, 2007, 09:07:15 pm »
just for future reference; what about multiple groups?

just add a comma, then a space, then the next number. in the list.

Abangyarudo

  • Guest
Re: Hiding Shop Button for members of a certain membergroup
« Reply #5 on: September 02, 2007, 09:08:45 pm »
I made the changes but I get this error
Parse error: parse error, unexpected T_GLOBAL, expecting ',' or ';' in /BlackRain1/index.template.php on line 949 that command is the global command

Code: [Select]
global $user_info;
« Last Edit: September 05, 2007, 10:40:20 am by Abangyarudo »

Abangyarudo

  • Guest
Re: Hiding Shop Button for members of a certain membergroup
« Reply #6 on: September 05, 2007, 10:40:32 am »
ok got some help from main smf site you move the command
Code: [Select]
echo to just after where it says
Code: [Select]
//loadLanguage("shop"); but group 1 which would be admin still sees it as well as other groups in the array so does moving the command invalidate the code?

Offline Daniel15

Re: Hiding Shop Button for members of a certain membergroup
« Reply #7 on: September 08, 2007, 12:22:58 pm »
The echo needs to be directly under the "if" statement. So, if you move the echo, also move the if statement.

Abangyarudo

  • Guest
Re: Hiding Shop Button for members of a certain membergroup
« Reply #8 on: September 10, 2007, 08:05:00 am »
The echo needs to be directly under the "if" statement. So, if you move the echo, also move the if statement.
it was under the global I moved it but still doesn't seem to be working

the code is currently
Code: [Select]
//Begin SMFShop code
global $user_info;
// Groups to hide the shop button from.
$shop_disabled_groups = array(1, 2, 3, 11, 12, 14);

// Only show the button if they're not in any of these groups.
if (!in_array($shop_disabled_groups, $user_info['groups']))
echo

//loadLanguage("shop");
($current_action == 'shop' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'shop' ? 'active_back' : 'back' , '">
</td>' , $current_action == 'shop' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
// Show the [Shop] button:
        echo '<li><a href="', $scripturl, '?action=shop" ><span>Shop</span></a></li>';
//END SMFShop code

Offline Daniel15

Re: Hiding Shop Button for members of a certain membergroup
« Reply #9 on: September 21, 2007, 10:47:59 am »
What's right above the
Code: [Select]
//Begin SMFShop bit?
And please remove the
Code: [Select]
//loadLanguage("shop");, it's not needed ;)

Edit: Looking at your code again, it should look something like:
Code: [Select]
//Begin SMFShop code
global $user_info;
// Groups to hide the shop button from.
$shop_disabled_groups = array(1, 2, 3, 11, 12, 14);

// Only show the button if they're not in any of these groups.
if (!in_array($shop_disabled_groups, $user_info['groups']))
echo '<li><a href="', $scripturl, '?action=shop" ><span>Shop</span></a></li>';
//END SMFShop code

The
Code: [Select]
($current_action == 'shop' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'shop' ? 'active_back' : 'back' , '">
</td>' , $current_action == 'shop' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
bit was for the default theme, and is not needed for this theme.
« Last Edit: September 21, 2007, 10:49:58 am by Daniel15 »

Abangyarudo

  • Guest
Re: Hiding Shop Button for members of a certain membergroup
« Reply #10 on: September 21, 2007, 03:32:32 pm »
What's right above the
Code: [Select]
//Begin SMFShop bit?
And please remove the
Code: [Select]
//loadLanguage("shop");, it's not needed ;)

Edit: Looking at your code again, it should look something like:
Code: [Select]
//Begin SMFShop code
global $user_info;
// Groups to hide the shop button from.
$shop_disabled_groups = array(1, 2, 3, 11, 12, 14);

// Only show the button if they're not in any of these groups.
if (!in_array($shop_disabled_groups, $user_info['groups']))
echo '<li><a href="', $scripturl, '?action=shop" ><span>Shop</span></a></li>';
//END SMFShop code

The
Code: [Select]
($current_action == 'shop' || $context['browser']['is_ie4']) ? '<td class="maintab_active_' . $first . '">&nbsp;</td>' : '' , '
<td valign="top" class="maintab_' , $current_action == 'shop' ? 'active_back' : 'back' , '">
</td>' , $current_action == 'shop' ? '<td class="maintab_active_' . $last . '">&nbsp;</td>' : '';
bit was for the default theme, and is not needed for this theme.

right above begin is
Code: [Select]
// Is the user allowed to administrate at all? ([admin])

  if ($context['allow_admin']){

echo '<li><a href="', $scripturl, '?action=admin"><span>', $txt[2], '</span></a></li>';
this is part of the search code

Abangyarudo

  • Guest
Re: Hiding Shop Button for members of a certain membergroup
« Reply #11 on: September 21, 2007, 04:00:53 pm »
ok I have the following error
Code: [Select]
Parse error: parse error, unexpected T_IF, expecting ',' or ';' in */smf/Themes/BlackRain1/index.template.php on line 959

this line is right below the editted smfshop code. it refers to the following line
Code: [Select]
if ($context['allow_edit_profile'])this shows the lines except whats above it which is the modified code you said it should say above I also showed a few lines below it. 
Code: [Select]
// Edit Profile... [profile]

if ($context['allow_edit_profile'])

echo '<li><a href="', $scripturl, '?action=profile"><span>', $txt[467], '</span></a></li>';

/*    // View Groups Interface... [groups]
 if (allowedTo('view_groups'))
    echo '<li><a href="', $scripturl, '?action=groups"><span>Groups</span></a></li>';

I also wanted to say thanks for helping me out as much as ya have .
« Last Edit: September 21, 2007, 04:04:47 pm by Abangyarudo »

Abangyarudo

  • Guest
Re: Hiding Shop Button for members of a certain membergroup
« Reply #12 on: October 02, 2007, 04:57:13 pm »
still having this problem and would apperciate any assistance. I do understand your very busy though.