Skip to Content Skip to Menu

[SOLVED] "Bonus" Plan Access

  • micheleq
  • micheleq
  • OFFLINE
  • Posts: 144
  • Thanks: 22
  • Karma: 6
7 years 7 months ago #292759 by micheleq
Replied by micheleq on topic "Bonus" Plan Access
Hi Kyle,

I suppose you could use a query field to query for their raw rank id then condition against that

I'm not sure what you mean by that. I didn't see a 'Query' option in the Field type there. Setting a query field in CB Fields?

I tested in the CB Auto Actions with this Query in the Action tab and setting with

Plan Active Gold
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var2] Equal To A
Action:
Code:
INSERT INTO #_user_usergroup_map (user_id, group_id) SELECT userid, 10 FROM #_kunena_users WHERE userid = [user_id] AND rank = 5;

Understanding that my
gold rank id = 5
gold usergroup id = 10
My id's have changed since my lasts post because I'm testing on a clean install, just to make sure there's nothing else interfering.

This didn't work, even when I removed the substitution field [user_id] for the actual id of the user I was testing. The query worked fine if I ran it in the phpmyadmin interface.

The other option I tried is to add another CB Action (with lower order) to run a Query before conditioning against the cb_heritage field.

Like this:

Plan Active Gold (query)
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var2] Equal To A
Action:
Code:
UPDATE #_comprofiler INNER JOIN#_kunena_users ON #_kunena_users.userid = #_comprofiler.user_id SET cb_heritage = '1' WHERE #_comprofiler.user_id = [user_id] AND #_kunena_users.rank = '5';


Plan Active Gold (usergroup)
Global
Triggers: onCPayUserStateChange
User: Automatic
Access: Everybody
Conditions
1: [var2] Equal To A
2: [cb_heritage] Equal To 1 (the corresponding cb_heritage field for Gold)
Action:
Enable usergroup Gold

This didn't work either. It seems that the "Query" on CB Actions is not executing for me, I don't know what I'm missing?

I can't think of anything else other than running an external cron to push the kunena rank value to the cb_heritage value.

Thank you,

Tomás

Code:
System Information of testing environment Setting Value PHP Built On Linux gator0.hostgator.com 3.12.65-188.ELK6.x86_64 #1 SMP Thu Oct 20 23:27:48 CDT 2016 x86_64 Database Version 5.5.51-38.2 Database Collation utf8_general_ci Database Connection Collation utf8mb4_general_ci PHP Version 5.6.29 Web Server Apache WebServer to PHP Interface cgi-fcgi Joomla! Version Joomla! 3.6.5 Stable [ Noether ] 1-December-2016 22:46 GMT Joomla! Platform Version Joomla Platform 13.1.0 Stable [ Curiosity ] 24-Apr-2013 00:00 GMT User Agent Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.98 Safari/537.36

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48548
  • Thanks: 8290
  • Karma: 1445
7 years 7 months ago #292784 by krileon
Replied by krileon on topic "Bonus" Plan Access

I'm not sure what you mean by that. I didn't see a 'Query' option in the Field type there. Setting a query field in CB Fields?

You'd use a CB Query Field to query for whatever value you need then you'd condition against it. In this case you need the raw rank id from Kunena so probably the below.

Code:
SELECT `rank` FROM `#__kunena_users` WHERE `userid` = '[user_id]'

I tested in the CB Auto Actions with this Query in the Action tab and setting with

Do not directly insert into _user_usergroup_map. Use the usergroup action which properly uses Joomla API to adjust usergroups.


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: micheleq

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

  • micheleq
  • micheleq
  • OFFLINE
  • Posts: 144
  • Thanks: 22
  • Karma: 6
7 years 7 months ago #292810 by micheleq
Replied by micheleq on topic "Bonus" Plan Access
Now I get it! I thought I had installed CB Query Field, but I had't done so in my test site.

Works like a charm.

I set my cb_heritage field to be a Query field and entered the query as you wrote it. I just rolled back my Gold and Platinum Active groups in CB Auto Actions to condition against cb_heritage. That was it.

Now I can automatically grant elevated access based on rank, posts, karma, thank-yous, or basically any filed from any component. This is great.

The problem I had before was that when a subscription (CB Subs) expired, if I had granted that specific user elevated access then they would not be blocked from access because of the extra access group assigned.

Now by automatically removing the extra group on expiration, and re-assigning it on renewal or new plan registration, the elevated access works automatically.

Thank you!
Tomás
The following user(s) said Thank You: nant, krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum