If user is in group x

Discussion forum for MOD Writers regarding MOD Development.
Locked
PSPfreaky
Registered User
Posts: 7
Joined: Wed Oct 29, 2014 1:05 pm

If user is in group x

Post by PSPfreaky »

Hello,

I'm making a page that is accessible for 3 different groups:
- Administrators (ID 5)
- Global moderators (ID 4)
- Premium (ID 11)

Now I want to make the page vissible in the menu for those groups. But I don't know exactly how to do that. I have:

Code: Select all

<!-- IF S_USER_LOGGED_IN and S_GROUP_ID_5 -->
<li><a href="/user/financial.php">Financial overview</a></li>
<!-- ENDIF -->
I am an administrator (5) but I don't see this page in the menu. But I need a final code for those 3 groups, like this: If user is logged in AND is in group_id 4 OR 5 OR 11.

Logged in + ID 4
Logged in + ID 5
Logged in + ID 11


I hope you can help me with this.

PSPfreaky

//
Sorry for my bad English

User avatar
Lumpy Burgertushie
Registered User
Posts: 67077
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: If user is in group x

Post by Lumpy Burgertushie »

you have to create a group switch first:

Open includes/functions.php

FIND

Code: Select all

    // The following assigns all _common_ variables that may be used at any point in a template.


BEFORE, ADD

Code: Select all


        if ( !function_exists('group_memberships') )
        {
            include($phpbb_root_path . 'includes/functions_user.'.$phpEx);
        }
        $groups = group_memberships(false,$user->data['user_id']);
        foreach ($groups as $grouprec)
        {
            $template->assign_vars(array(
            'S_GROUP_' . $grouprec['group_id'] => true
            ));
        }


then use the switch like so

Code: Select all

  <!-- IF S_GROUP_2 -->some stuff here<!-- ENDIF -->
robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
noth
Registered User
Posts: 2482
Joined: Fri Jan 07, 2005 7:10 pm
Location: North Surrey
Contact:

Re: If user is in group x

Post by noth »

can I add a panel to my index page for my subscribers in 3.1.2?

I want to also do an advert to my members who are NOT subscribers also not visible to my subscibers

once they paid I want the advert for subscribers to not be visible to the subscribers

so in 3.1.2. is <!-- IF S_GROUP_2 -->some stuff here<!-- ENDIF --> going to work?

or do we have to do that Open includes/functions.php and add a paragraph in there first? that's not really the 3.1 way is it? so even for something this simple we're looking at an extension ?

User avatar
Lumpy Burgertushie
Registered User
Posts: 67077
Joined: Mon May 02, 2005 3:11 am
Contact:

Re: If user is in group x

Post by Lumpy Burgertushie »

dont know if the edit to the php file will still be exactly the same in 3.1, but you can always do edits to the files if you wish. also, you can't just call something that depends on whether someone is in a group with just the html switch without creating the switch in the php files first.

however, the best way is to request an extension so you do not have to redo any changes each time you have to update 3.1
even to just change the html it should be done with an extension. especially if you are using a different style.

that way, even with different styles, updates to the board or to your style will still work.


robert
I'm baaaaaccckkkk. still doing work on donation basis. PM your needs.

Premium phpBB 3.3 Styles by PlanetStyles.net

If a tree falls in the forest and nobody is there, does it make a sound?

User avatar
noth
Registered User
Posts: 2482
Joined: Fri Jan 07, 2005 7:10 pm
Location: North Surrey
Contact:

Re: If user is in group x

Post by noth »

ok I'll do a request for an extension

just so that <!-- IF S_GROUP_2 -->some stuff here<!-- ENDIF --> will actually work

seems like <!-- IF S_GROUP_2 -->some stuff here<!-- ENDIF --> should work anyway without an extension :x but there you go

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 21034
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: If user is in group x

Post by RMcGirr83 »

You will have to create your own event html files. Read the "Readme.md" file.

https://github.com/phpbbmodders/phpbb-3 ... roupswitch
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

Locked

Return to “[3.0.x] MOD Writers Discussion”