Keyword

Menu Item restriction based on K2 user group

  • Amy Sheffer
  • Amy Sheffer's Avatar Topic Author
  • Offline
  • New Member
More
14 years 2 months ago #86183 by Amy Sheffer
I will have several clients who will have access to restricted content. Once they are logged in, I need a specific client to see only the content that relates to them.I had hoped that setting up a K2 user group for each client and restricting access to a specific K2 category would keep the user from seeing another client's K2 Items.I have a Joomla mod_mainmenu called "Client Menu" which has links to each client's K2 items. I would like to restrict the menu items in the menu so that only the menu items that link to the client's K2 items are visible to that client.Is there a mod for this? I am a PHP developer, so I can edit code myself. But, I would love to find a mod or plugin. If I need to edit the code myself, can someone point me in the right direction? I am sure I am not the only person who has hoped for this functionality.Thank you!

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

More
14 years 1 month ago #86184 by Simon Wells
Replied by Simon Wells on topic Menu Item restriction based on K2 user group
The way I do this, is to create a category for each user, that way, in the user group you can limit access to just that category.
Then through the menu, you link to the category they have access to with permission set to registered..

No non-registered can then see the menu and the menu tem can only be accessed by that user.

I hope that helps a little.

Simon
K2 Support

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

  • Amy Sheffer
  • Amy Sheffer's Avatar Topic Author
  • Offline
  • New Member
More
14 years 1 month ago #86185 by Amy Sheffer
Replied by Amy Sheffer on topic Menu Item restriction based on K2 user group
I don't know why I didn't think of that. Your suggestion is quick and easy. Thank you for sending it along. I ended up making a new menu for each client and using MetaMod to control access based on user.

I'll keep your solution in my docs though... I'm sure this won't be the last time I have this requirement.

Simon Wells (K2 Support) said:The way I do this, is to create a category for each user, that way, in the user group you can limit access to just that category. Then through the menu, you link to the category they have access to with permission set to registered..

No non-registered can then see the menu and the menu tem can only be accessed by that user.

I hope that helps a little.

Simon
K2 Support

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

More
14 years 1 month ago #86186 by James Kennedy
Replied by James Kennedy on topic Menu Item restriction based on K2 user group
Your posting was very helpful. Using MetaMod I was able to show and hide a menu module based on a K2 user group. For others that may be interested. The snippet of PHP code I used in the MetaMod looks like this:

$userid = $user->id;

$query = "select * FROM jos_k2_users as a WHERE userID = '$userid';";

$db->setQuery( $query );

$row = $db->loadObject();

$group = $row->group;

if ( $group == 3 && $approv == 1 ) return 47;

$group is the K2 user group I want to allow access for. 47 is the id of the menu module I want to display.

Hopefully this can safe somebody else looking for the same solution some time.

Amy Sheffer said:I don't know why I didn't think of that. Your suggestion is quick and easy. Thank you for sending it along. I ended up making a new menu for each client and using MetaMod to control access based on user.
I'll keep your solution in my docs though... I'm sure this won't be the last time I have this requirement.

Simon Wells (K2 Support) said:The way I do this, is to create a category for each user, that way, in the user group you can limit access to just that category. Then through the menu, you link to the category they have access to with permission set to registered..
No non-registered can then see the menu and the menu tem can only be accessed by that user.

I hope that helps a little.

Simon
K2 Support

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

More
14 years 1 month ago #86187 by James Kennedy
Replied by James Kennedy on topic Menu Item restriction based on K2 user group
Posted the wrong snippet:

$userid = $user->id;

$query = "select * FROM jos_k2_users WHERE userID = '$userid';";

$db->setQuery( $query );

$row = $db->loadObject();

$group = $row->group;

if ( $group == 3 ) return 47;

Jim Kennedy said:Your posting was very helpful. Using MetaMod I was able to show and hide a menu module based on a K2 user group. For others that may be interested. The snippet of PHP code I used in the MetaMod looks like this:

$userid = $user->id;

$query = "select * FROM jos_k2_users as a WHERE userID = '$userid';";

$db->setQuery( $query );

$row = $db->loadObject();

$group = $row->group;

if ( $group == 3 && $approv == 1 ) return 47;

$group is the K2 user group I want to allow access for. 47 is the id of the menu module I want to display.

Hopefully this can safe somebody else looking for the same solution some time.

Amy Sheffer said:I don't know why I didn't think of that. Your suggestion is quick and easy. Thank you for sending it along. I ended up making a new menu for each client and using MetaMod to control access based on user. I'll keep your solution in my docs though... I'm sure this won't be the last time I have this requirement.

Simon Wells (K2 Support) said:The way I do this, is to create a category for each user, that way, in the user group you can limit access to just that category. Then through the menu, you link to the category they have access to with permission set to registered.. No non-registered can then see the menu and the menu tem can only be accessed by that user.

I hope that helps a little.

Simon
K2 Support

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

  • Amy Sheffer
  • Amy Sheffer's Avatar Topic Author
  • Offline
  • New Member
More
14 years 1 month ago #86188 by Amy Sheffer
Replied by Amy Sheffer on topic Menu Item restriction based on K2 user group
Here's the snippet I used:

if($user->id == "64"){
return 30;
}
elseif($user->id == "63") {
return 29;
}
else {
return;
}

The return values are the ids of the menus. Each client has their own menu module. The rest should be self-explanatory, but feel free to reply with questions. I'll monitor this thread.


Jim Kennedy said:Posted the wrong snippet: $userid = $user->id;

$query = "select * FROM jos_k2_users WHERE userID = '$userid';";

$db->setQuery( $query );

$row = $db->loadObject();

$group = $row->group;

if ( $group == 3 ) return 47;

Jim Kennedy said:Your posting was very helpful. Using MetaMod I was able to show and hide a menu module based on a K2 user group. For others that may be interested. The snippet of PHP code I used in the MetaMod looks like this: $userid = $user->id;

$query = "select * FROM jos_k2_users as a WHERE userID = '$userid';";

$db->setQuery( $query );

$row = $db->loadObject();

$group = $row->group;

if ( $group == 3 && $approv == 1 ) return 47;

$group is the K2 user group I want to allow access for. 47 is the id of the menu module I want to display.

Hopefully this can safe somebody else looking for the same solution some time.

Amy Sheffer said:I don't know why I didn't think of that. Your suggestion is quick and easy. Thank you for sending it along. I ended up making a new menu for each client and using MetaMod to control access based on user. I'll keep your solution in my docs though... I'm sure this won't be the last time I have this requirement. Simon Wells (K2 Support) said:The way I do this, is to create a category for each user, that way, in the user group you can limit access to just that category. Then through the menu, you link to the category they have access to with permission set to registered.. No non-registered can then see the menu and the menu tem can only be accessed by that user. I hope that helps a little.

Simon
K2 Support

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

More
13 years 8 months ago #86189 by Yuma Scott
Replied by Yuma Scott on topic Menu Item restriction based on K2 user group
Hello Simon,

I used your posted suggestion however my menu item is still allowing any registered user who is not in the specific user group to access the menu item.

Any suggestions?

 

Thanks,

YumaSimon Wells (K2 Support) said:

The way I do this, is to create a category for each user, that way, in the user group you can limit access to just that category.Then through the menu, you link to the category they have access to with permission set to registered..No non-registered can then see the menu and the menu tem can only be accessed by that user.I hope that helps a little.SimonK2 Support

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


Powered by Kunena Forum