Template variable for checking group membership

Support for mods released by phpbbmodders.net found at either https://github.com/phpbbmodders/ or the MODDB at http://www.phpbb.com
Forum rules
Please only request support for mods released by phpbbmodders.net found at either https://github.com/phpbbmodders/ or the MODDB at http://www.phpbb.com
User avatar
RMcGirr83
Supporter
Supporter
Posts: 6242
Joined: 30 Nov 2006, 14:23
Real name: Rich McGirr

Re: Template variable for checking group membership

Post by RMcGirr83 »

No, that is not the purpose of this mod.
sonoma
New member
New member
Posts: 4
Joined: 12 Feb 2014, 04:14

Re: Template variable for checking group membership

Post by sonoma »

Well thanks for this mod, I use it as well. Could you possibly point me the way to what I am looking for? I only need to check against a handful of groups to simply display an image or not to display an image to everyone if that user is in a group or not.
sonoma
New member
New member
Posts: 4
Joined: 12 Feb 2014, 04:14

Re: Template variable for checking group membership

Post by sonoma »

I managed to cook this up by altering a snippet a person named cherokee red created which appears to be working just the way I want, which is the opposite of your code. However I am not sure if this is the best way to achieve the results, this goes in viewtopic.php.

Code: Select all

// Check what group a user is in
    if ( !function_exists('group_memberships') )
    {
        include_once($phpbb_root_path . 'includes/functions_user.'.$phpEx);
    }
   $groups = group_memberships(false,$poster_id);
        foreach ($groups as $poster_groups)
        {
          $template->assign_vars(array(
            'S_GRP_CHK_' . $poster_groups['group_id'] => true
            ));
      }
sonoma
New member
New member
Posts: 4
Joined: 12 Feb 2014, 04:14

Re: Template variable for checking group membership

Post by sonoma »

scratch the above, it works the same way.
neuropass
Member
Member
Posts: 66
Joined: 12 Apr 2010, 17:07

Re: Template variable for checking group membership

Post by neuropass »

@Rich,

Code: Select all

last edited by RMcGirr83 on 13 Jan 2015, 01:00, edited 9 times in total.
Reason: fixed code if not in group
Whats the fix specifically? If statement or the php code?
User avatar
RMcGirr83
Supporter
Supporter
Posts: 6242
Joined: 30 Nov 2006, 14:23
Real name: Rich McGirr

Re: Template variable for checking group membership

Post by RMcGirr83 »

The code to use in the html files.
neuropass
Member
Member
Posts: 66
Joined: 12 Apr 2010, 17:07

Re: Template variable for checking group membership

Post by neuropass »

something else was changed.

what the difference between:

Code: Select all

if ($users_groups)
and:

Code: Select all

if (sizeof($groups))
User avatar
RMcGirr83
Supporter
Supporter
Posts: 6242
Joined: 30 Nov 2006, 14:23
Real name: Rich McGirr

Re: Template variable for checking group membership

Post by RMcGirr83 »

if ($users_groups)

checks if variable is set

if (sizeof($groups))

checks to ensure that the array that is generated has something in it.

Not sure why it matters, just use the code in the first post.
Post Reply