CB Auto-Actions with Usergroups and Ranks

6 days 9 hours ago - 6 days 8 hours ago #326328 by ml25
Hello JoomlaPolis Team,

I am reaching out to you because currently I have a site offering classes with only one paid subscription plan giving access to everything at the moment and we would like to add two other cheaper plans and give access to different areas of the site (for example we have one with all the classes and the forum, and we'd like to add one with all the classes but with only the announcements part of the forum and another one with classes on one specific subject with specific parts of the forum). The site uses CB integrated with a kunena forum and ranks are a part of it, which are displayed on each member's profile page and forum posts.

Each subscription plan assigns a member to a specific usergroup (for example, the “Member 1” plan assigns the member to the “Member 1” usergroup) and depending on the Access Levels set up, they have access to specific pages according to the usergroup they belong to.

All of this is working well so far but I am stuck at one point. I would like each usergroup to be automatically assigned to a kunena rank. So if a person subscribes to the “Member 1” plan, then this person is assigned to the corresponding usergroup by CB and I’d love that this member be assigned to the “Member 1” rank on Kunena. And if a person subscribes to the “Member 2” plan, then they’ll be assigned to “Member 2” usergroup and I’d love this member to be assigned with the “Member 2” rank. So that each usergroup has its own rank.

And if they change their subscription plan and then their usergroup, they are assigned to the new corresponding rank.

Since it is not possible to do this through kunena directly yet, I thought about using CB Auto-Actions which seems to enable this kind of actions and I have tried to make it work in trying to understand it intuitively since I am new to it but it doesn’t.

I am sharing with you the settings I tried to do what I’d like to,

Global Tab
Triggers : onAfterNewUser, onAfterUpdateUser, onAfterUserApproval, onAfterUserRegistration, onAfterUserUpdate
Type : Field
User : Automatic
Access : Everybody

Conditions Tab
Field : Usergroups
User : Action User
Operator : Has
Usergroups : Member 1

Action Tab
Field : cb_forumrank (I tried with “cb_forumrank_title” instead too)
Operator : Set (Field = Value)
Value : Member 1 (I tried putting the kunena rank ID number instead too)
Translate Value : No
Save Directly : Yes
User : (blank)

And for the other tabs, I didn’t change anything.

I simulated a registration with “Member 1” subscription plan which assigned me to the “Member 1” usergroup automatically but it didn’t do anything and didn’t change to the “Member 1” rank.

I tried with the other subscription plans / usergroups but it didn't work either.

Could you please help me understand what can I do differently for this to work and what is missing ?

Thank you in advance and best wishes,
Mathias

Please Log in to join the conversation.

4 days 15 hours ago #326360 by krileon
Replied by krileon on topic CB Auto-Actions with Usergroups and Ranks
You'll need to change their rank directly in Kunena. Best way I can suggest to do that based off plan selection is to use the CBSubs SQL Actions integration then use the following query.

SQL Action 1
Activation:
UPDATE `#__kunena_users` SET `rank` = RANK_ID_HERE WHERE `userid` = '[user_id]'

RANK_ID_HERE should be whatever the rank id is within Kunena > Ranks.


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.
The following user(s) said Thank You: ml25

Please Log in to join the conversation.

1 day 8 hours ago - 1 day 8 hours ago #326405 by ml25
Hi Kyle,

Thank you for your help and fast answer!

I didn’t know we could add a SQL Query to a CBSubs Plan directly, this is great.

I tried to add the SQL query in the integration tab of a CB Plan after having installed SQL Actions on my local site and unfortunately it didn’t work.

I have been looking for the issue and I think I found it. Actually when a person subscribes, it is registered in #__comprofiler database but not in #__kunena_users db.

The user is not registered in #__kunena_users db until I go to “components > kunena > tools > sync users” and I synchronize users by asking to “add a user profile for everyone”.

Then, after having done that, the rank is automatically set to the default one.

But if I add the SQL query in the “Renewal” area of SQL Actions in a Plan and the member’s subscription expires, when he comes back and subscribes again, then it works fine and he has the good rank.

So I guess the solution is to have the person being registered in #__kunena_users db directly after his registration to have the good rank set in rank column right away.

A solution would be to manually add a member after his/her registration on Kunena to have him/her on #__kunena_users db (by syncing users in kunena settings), set the rank manually through Kunena for the first time and then when the person changes his/her membership plan, it should change automatically to the new rank since he/she is in #__kunena_users db. I have just tried it and it works.

However, I would like to know if this is possible to register the person automatically in #__kunena_users db as soon as he/she is registered both on the site and in #__comprofiler db, both being synced, so that everything is done by the site itself without me having to do it manually ?

I tried to find something in Kunena and CB settings but I didn’t find anything and didn’t find the solution here on Joomlapolis either yet.

Thank you again and best wishes,
Mathias

Please Log in to join the conversation.

14 hours 53 minutes ago #326412 by krileon
Replied by krileon on topic CB Auto-Actions with Usergroups and Ranks
Do you have Kunena setup to integrate with CB? I was pretty sure it's supposed to keep the users in sync if setup correctly. Specifically ensure within Kunena > Plugins that "Kunena - Community Builder Integration" is published and that within Extensions > Plugins "System - Kunena Forum" is also published.

The only other option is to use CB Auto Actions or to improve the query to also insert the user if they don't exist. The below for example should work using CB Auto Actions.

Plan Active
Global
Triggers: onCPayUserStateChange
Type: Kunena
User: Automatic
Access: Everybody
Conditions
Condition 1
Field: Custom > Value
Custom Value: [var3]
Operator: Equal To
Value: PLAN_ID_HERE
Condition 2
Field: Custom > Value
Custom Value: [var2]
Operator: Equal To
Value: A
Action
Mode: Synchronize
Field: Rank
Value: RANK_ID_HERE

Be sure to replace PLAN_ID_HERE with your plan id that you want this to apply to and replace RANK_ID_HERE with the rank you want to give them.

Note you'll need to update to latest just release CB Auto Actions build as I've just added support for synchronizing the rank.


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.171 seconds

Facebook Twitter LinkedIn