Skip to Content Skip to Menu

Auto action with dynamic user

  • activha
  • activha
  • OFFLINE
  • Posts: 2327
  • Thanks: 117
  • Karma: 13
10 years 11 months ago #238016 by activha
Auto action with dynamic user was created by activha
Hello Kyle

I would like to create an auto action for connecting new registered users to their sponsor using the inputed sponsor code.

For instance if sponsor code = jkljkl I would like the new user who has correctly inserted this code to be automatically connected with this sponsor.

I tried with auto action connection but dont see what to insert in the user to connect to field.

Can you help me ?
Thanks

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 11 months ago #238032 by krileon
Replied by krileon on topic Auto action with dynamic user
You need a field for them to supply the user id of the user they're going to connect to. If you don't want that then you need a CB Query Field to try and query for their sponsors user id. Next configure the Connection action as follows.

Action: Connection
Trigger: after login? after registration? (up to you)
Access: Everybody
Conditional 1: [cb_mysponsor] Not Empty
Users: [cb_mysponsor]

In the above example the cb_mysponsor field is your sponsor user id field or CB Query Field that finds sponsor user id. The query for the query field could be for example as follows.

Code:
SELECT `id` FROM `#__comprofiler` WHERE `cb_sponsor` = '[cb_sponsorcode]'


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.

  • activha
  • activha
  • OFFLINE
  • Posts: 2327
  • Thanks: 117
  • Karma: 13
10 years 5 months ago - 10 years 5 months ago #245220 by activha
Replied by activha on topic Auto action with dynamic user

CB Query Field that finds sponsor user id. The query for the query field could be for example as follows.


It does not seem to work with a CB query field, I have even moved up the CB query field plugin above auto action plugin but no chance.

Could you check on your side ?

Is there a way to move the result of the query to a static field ?

If I set up the afterlogin trigger, will it gives bad results after the first time ? or if the connection already exists will it just fail gracely without overloading something ?
Last edit: 10 years 5 months ago by activha.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48478
  • Thanks: 8282
  • Karma: 1443
10 years 5 months ago #245250 by krileon
Replied by krileon on topic Auto action with dynamic user

It does not seem to work with a CB query field, I have even moved up the CB query field plugin above auto action plugin but no chance.

Check the field on the users profile to ensure it's outputting correctly. The field must be set to display on profile for its substitution to work. If you don't want it actually visible then move it to a tab that's in a not shown on profile position.

Is there a way to move the result of the query to a static field ?

You'd need another CB Auto Action to store it to another CB field. You don't need to do this though as substitutions use getField API, which will pull the query field results fine. This assumes the user object is properly present.

If I set up the afterlogin trigger, will it gives bad results after the first time ?

I don't know what you mean by bad results. With the after login trigger the user is logged in and their user object exists. So it should be fine assuming the query is correct and its substitution outputs a value.

or if the connection already exists will it just fail gracely without overloading something ?

If the connection already exists it just skips it.


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