Skip to Content Skip to Menu

SQL Action logging

9 years 5 months ago #266183 by derekkoopowitz
SQL Action logging was created by derekkoopowitz
Joomla 3.4.1
CB 2.09
CB Subs 4.0 Stable

I created a SQL action to assign an additional user group to a user after a plan is activated/renewed by doing an insert to the user_usergroup_map table. The SQL action seems to work (I don't get any errors) however when querying the table I do not see the new record.

Is there a specific sequence of events that take place when a plan is purchased/renewed? In other words, I have a specific group that is assigned to the user when they purchase a plan (Member) which does get assigned correctly. The SQL action is then assigning an additional group to the user (I'd really like to multi-select user groups on plan purchases)... and I'm wondering if this is actually taking place. Is there a log file that I can browse that shows a history of the actions taking place on a user after they purchase a plan?

I've run this SQL using phpMyAdmin and it works perfectly (including the delete when they expire).

My code is as follows (the number 10 below is the group id that I'd like to assign to the user):

INSERT INTO `#__user_usergroup_map` (user_id, group_id) VALUES ([user_id], 10);

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48548
  • Thanks: 8290
  • Karma: 1445
9 years 5 months ago #266193 by krileon
Replied by krileon on topic SQL Action logging
Doing a direct database insert won't update the users session. This means if they're already logged in they won't see the new usergroup until they logout. Ensure your usergroup is visible in backend and it'll be working fine, but the user won't know until they've logged out and logged back in.


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 or Create an account to join the conversation.

9 years 5 months ago #266199 by derekkoopowitz
Replied by derekkoopowitz on topic SQL Action logging

krileon wrote: Doing a direct database insert won't update the users session. This means if they're already logged in they won't see the new usergroup until they logout. Ensure your usergroup is visible in backend and it'll be working fine, but the user won't know until they've logged out and logged back in.


Thanks Kyle. I don't think I was specific... when I checked the usergroup table, I checked it using the backend as well as using phpMyAdmin to query the table. In both cases, the update to the user group wasn't made.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48548
  • Thanks: 8290
  • Karma: 1445
9 years 5 months ago #266446 by krileon
Replied by krileon on topic SQL Action logging
That's probably due to it not being stored with the user object and session. If the user object and session aren't updated a user store following your query will basically just undo what you've done. The best way to have what you're wanting right now is with CB Auto Actions and its Usergroup action, but that requires a Professional subscription or use only 1 usergroup per plan and let CBSubs control it from the Access tab.


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 or Create an account to join the conversation.

9 years 5 months ago #266513 by derekkoopowitz
Replied by derekkoopowitz on topic SQL Action logging

krileon wrote: That's probably due to it not being stored with the user object and session. If the user object and session aren't updated a user store following your query will basically just undo what you've done. The best way to have what you're wanting right now is with CB Auto Actions and its Usergroup action, but that requires a Professional subscription or use only 1 usergroup per plan and let CBSubs control it from the Access tab.


That's why I wanted to know the sequence of events... do SQL Actions get done first before CBSubs updates all relevant data, or is it done afterwards? The reason for the two types of user groups is that access to certain parts of the website are given with a membership purchase but can also be purchased separately for a small fee - thus the need for the two groups. I'll have to see if my other component will allow multiple groups to access the data... that way I can leave it as is and just multi-select the groups with the other component.

Thanks for the candid feedback.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48548
  • Thanks: 8290
  • Karma: 1445
9 years 3 months ago #268796 by krileon
Replied by krileon on topic SQL Action logging
The user store happens after the SQL actions. Since your SQL is not updating the user object nor the Joomla session (usergroups are stored there if the user is logged in) then they'll be overridden by the user store. CB Auto Actions usage works as it causes a proper user store and session update with its Usergroup action. CBSubs usergroup change does the same thing, but at this time it's only designed for giving 1 usergroup. You could use a parent > child relationship for your groups though and the parent could give 1 usergroup while the child plan gives the other.


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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum