Keyword

Use $K2UserGroup variable in a template

  • renegadesk
  • renegadesk's Avatar Topic Author
  • Offline
  • New Member
More
13 years 7 months ago #93491 by renegadesk
Use $K2UserGroup variable in a template was created by renegadesk
Looking to find out how to use the $K2UserGroup variable (or just any way to find out the users user group!) in a template file.

 

I can see the variable in com_k2/helpers/permissions.php on line 26 in the class K2HelperPermissions

 

If there is a way that I can use the current user's group as a variable in the template code that would be beyond awesome. 

Please Log in or Create an account to join the conversation.

  • renegadesk
  • renegadesk's Avatar Topic Author
  • Offline
  • New Member
More
13 years 7 months ago #93492 by renegadesk
Replied by renegadesk on topic Use $K2UserGroup variable in a template
ok I managed to get it done. But then I realised that I needed to have my users in multiple groups. So then I installed JUGA just for the multiple groups feature so then I needed to modify my code.

 

Now I've got the categories set up so users only see categories that have the same names as the group they are in.

e.g. user test in groups clients and project 1 can only see these categories.

 

It outputs either the K2 group or the JUGA groups as a variable or an array respectively to be used within the template files. Let me know if anyone would fine this interesting and I can post it up.

 

One shortcoming though is that if the user has a link to another category that they are not in a group for it will bypass this system and let them access it. Surely not too hard to work out so I might only do that if required.

Please Log in or Create an account to join the conversation.

More
13 years 7 months ago #93493 by Mark Law
Replied by Mark Law on topic Use $K2UserGroup variable in a template
Awesome work Simon, this is super useful for sure.

 

I have many clients who would be interested in this. I actaully assumed this kind of acl was built into K2! alas it is not so well done for coding this up. Keep us posted on developments.

 

Hopefully this will be added to the core of future releases so that K2 catches up with J1.6.

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum