Maximum Number of Groups

2 years 3 months ago #327860 by MarlonFungai
Maximum Number of Groups was created by MarlonFungai
I want to implement a maximum number of groups in a specific category of GroupJive groups for a user. The use case is that we have groups that represent students from different universities and each student can only be a member of 1 university at time. How could I go about this?

Please Log in to join the conversation.

2 years 3 months ago #327872 by krileon
Replied by krileon on topic Maximum Number of Groups
You want to limit the number of groups they can join within a category or number of groups they can create within a category? There isn't functionality of either out of the box, but both are doable using CB Auto Actions. Will provide examples once you confirm which you're needing.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

2 years 3 months ago #327878 by MarlonFungai
Replied by MarlonFungai on topic Maximum Number of Groups
I want to limit the number of groups they can join within a category.

Please Log in to join the conversation.

2 years 3 months ago #327883 by krileon
Replied by krileon on topic Maximum Number of Groups
Ok, the below should be able to do that. It'll interrupt the join process if they've already joined a group in a specific category.

Global
Triggers: gj_onBeforeJoinGroup
Type: Code
User: Automatic
Access: Everybody
Conditions
Field: Custom > Query
Query:
SELECT u.`id`
 FROM `#__groupjive_users` AS u
 INNER JOIN `#__groupjive_groups` AS g
 ON g.`id` = u.`group`
 INNER JOIN `#__groupjive_categories` AS c
 ON c.`id` = g.`category`
 WHERE u.`user_id` = '[user_id]'
 AND c.`id` = CATEGORY_ID_HERE
Operator: Not Empty
Action
Method: PHP
Code:
$variables['var1']->setError( 'You have already joined a group in this category.' );


Replace CATEGORY_ID_HERE in the query condition with the category you want to check against. You can adjust the error message to whatever you'd like it to say. There isn't a way to suppress the display of the join button though. Can consider adding a way of doing that to GJ if necessary.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.269 seconds

Facebook Twitter LinkedIn