Skip to Content Skip to Menu

Autoaction change group based on a custom query

  • aroma
  • aroma
  • OFFLINE
  • Posts: 15
  • Thanks: 1
  • Karma: 0
1 year 4 months ago #334106 by aroma
Good morning,
I should use Auto Action plugin using login trigger to check on a user field is included in the result of a custom query, then change its group.

I have to check that a particular number given by the user is among those enabled in a custom table in the database.

How can I do?

Thanks

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48419
  • Thanks: 8274
  • Karma: 1443
1 year 4 months ago #334108 by krileon
You'd use a usergroup action on the after login trigger in that case. Auto Action conditions support custom queries so checking a value in a separate database table won't be a problem. Example as follows.

Global
Triggers: onAfterLogin
Type: Usergroup
User: Self
Access: Everybody
Conditions
Condition 1
Field: Usergroups
User: Action User
Operator: Does Not Have
Usergroups: USERGROUP_HERE
Condition 2
Field: Query
Custom Query: YOUR_SQL_HERE
Operator: Equal To
Value: PARTICULAR_NUMBER_HERE
Action
Method: Add Usergroups
Groups: USERGROUP_HERE

The conditions ensure they don't already have the usergroup you want to assign them and check against the result of your database query.


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.

  • aroma
  • aroma
  • OFFLINE
  • Posts: 15
  • Thanks: 1
  • Karma: 0
1 year 4 months ago - 1 year 4 months ago #334120 by aroma
Thanks for the reply.

I add a condition:
my_field
NOT EMPTY

This because some user coult leave empty the field.
But if user don't have the fileld when the user login he get the following error:

:: Action 100 :: Condition 1-4 failed for user 667 with "" Not Empty ""
Last edit: 1 year 4 months ago by aroma.

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

  • krileon
  • krileon
  • OFFLINE
  • Posts: 48419
  • Thanks: 8274
  • Karma: 1443
1 year 4 months ago #334123 by krileon

But if user don't have the fileld when the user login he get the following error:

Turn off debug mode for the auto action. It only outputs debug information if you have debugging enabled in it. The condition is working correctly as empty field value is indeed empty so it fails the not empty check.


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.

  • aroma
  • aroma
  • OFFLINE
  • Posts: 15
  • Thanks: 1
  • Karma: 0
1 year 4 months ago #334127 by aroma
That work!
Thank you!
The following user(s) said Thank You: krileon

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

Moderators: beatnantkrileon
Powered by Kunena Forum