Group Statement

Guides & Snippets for phpBB3. Try the Snippets here and share Your own Snippets
There is no support here! Only Read Access!
Locked
User avatar
Post Bot
BBCoder II
BBCoder II
Posts: 44
Joined: 04 Mar 2010, 20:53

Group Statement

Post by Post Bot »

Group Statement
Code by RMcGirr83

This code can be used to show specific content to specific groups, or the other way around.
It could be that you want to display ads for registered users, but not your VIP Group.

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
        ));
    }
Now you can use the group statement in the templates.
If you you want to show some content to a specific group:

Code: Select all

<!-- IF S_GROUP_ID -->Content here<!-- ENDIF -->
Or if you want to show some content like ads to all groups except one:

Code: Select all

<!-- IF not S_GROUP_ID -->Content here<!-- ENDIF -->
You have to change the ID in the code with the actual group ID which is a number.
Locked