I keep loosing this snippet and quite often I notice people asking for it, so I decided to post it here.
#
#-----[ OPEN ]------------------------------------------
#
includes/functions.php
#
#-----[ FIND ]------------------------------------------
#
Code: Select all
// application/xhtml+xml not used because of IE
header('Content-type: text/html; charset=UTF-8');
#
#-----[ 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']);
if (sizeof($groups))
{
foreach ($groups as $grouprec)
{
$template->assign_vars(array(
'S_GROUP_' . $grouprec['group_id'] => true)
);
}
}
Now on any page, you should be able to use this switch
Code: Select all
<!-- IF S_GROUP_X -->
Just replace X with ID of the group. You can also expand on that and add multiple groups and/or any other template function that is built into phpBB
Code: Select all
<!-- IF (S_GROUP_1 or S_GROUP_2) --> // if user is in either of the groups
Code: Select all
<!-- IF (S_GROUP_1 and S_GROUP_2) --> // User has to be in both groups to return true
Code: Select all
<!-- IF not S_GROUP_X --> // Show for all except that group