[SOLVED] CB triggers order

4 years 2 months ago - 4 years 2 months ago #316132 by activha
[SOLVED] CB triggers order was created by activha
Hello

We need to update a DB table during the registration process, before any CBsubs trigger and it seems that onAfterUserRegistration does not update the table.

We have :
1) CB registration
2) a plugin using the trigger onUserAfterSave to create a new user in its table (AffiliateTracker component)
3) a payment with CBsubs for any chosen plan

We would like to update the AffiliateTracker table just after the user has been saved by CB in order to reflect any affiliate parent id and use the following request auto action with a condition of [cb_codeatid] field not null
UPDATE `#__affiliate_tracker_accounts`  SET `parent_id` = '[cb_codeatid]' WHERE `user_id` = '[user_id]'

The auto action works well with a login trigger for instance, but fails to update the table with onAfterUserRegistration

We also tried with onAfterUserSaveRegistration, onAfterNewUser or joomla_onUserAfterSave without success

Can you help us on this ?
Is there any order documented somewhere for the CB triggers ?
Do we need to use another one ? knowing that we want the table to be updated before any CBsubs trigger being fired ?

Thanks for your input
Jean

Please Log in to join the conversation.

4 years 2 months ago #316133 by krileon
Replied by krileon on topic CB triggers order

We need to update a DB table during the registration process, before any CBsubs trigger and it seems that onAfterUserRegistration does not update the table.

onAfterUserRegistration is the correct trigger. It fires directly after the user object is stored successfully. It however only applies to frontend so if you're creating users from backend you need to use onAfterNewUser. Do you have a redirect action acting on or before that trigger that maybe could be interrupting your query action?

We would like to update the AffiliateTracker table just after the user has been saved by CB in order to reflect any affiliate parent id and use the following request auto action with a condition of [cb_codeatid] field not null

Your condition is likely what is failing. If you're checking if the value is null it's just checking if the field is equal to the string null. Use a "Is Empty" or "Is Not Empty" condition.


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.

4 years 2 months ago #316139 by activha
Replied by activha on topic CB triggers order

Use a "Is Empty" or "Is Not Empty" condition.


This is an integer number field, so it may be equal to zero, in this case will empty still works ?

Do you have a redirect action acting on or before that trigger that maybe could be interrupting your query action?

No we don't have any redirects.
We added both onAfterNewUser and onAfterUserRegistration but no success up to now.

What is strange is that if I use onAfterFirstLogin to test, the auto action fires successfully

Please Log in to join the conversation.

4 years 2 months ago #316143 by krileon
Replied by krileon on topic CB triggers order

This is an integer number field, so it may be equal to zero, in this case will empty still works ?

Yes, but if it's integer it's usually best to just check that its value is greater than 0.

What is strange is that if I use onAfterFirstLogin to test, the auto action fires successfully

Does the field you're conditioning against exist during registration and is accessible to the user? Beyond that I've no idea. You're using the correct trigger. Enable debug mode and maximum error reporting in Joomla global configuration then enable debugging for the auto action within its parameters. That should output any errors it may have including if a condition fails and what values it saw.


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.

4 years 2 months ago #316147 by activha
Replied by activha on topic CB triggers order

Does the field you're conditioning against exist during registration and is accessible to the user?

Yes the field is even validated by a query at registration to check it's ok and existing.

Do you have any other trigger that will fire before any first payment in case there is a CBsubs subscription ?
If yes we could do with after first login to update the table

Please Log in to join the conversation.

4 years 2 months ago - 4 years 2 months ago #316149 by krileon
Replied by krileon on topic CB triggers order
There are several CBSubs triggers available and are included in the triggers dropdown. Regardless your auto action should be working as is on the after registration trigger. Something is either interrupting it or it's failing somehow. Have you tested with debugging to see if any errors output? Is CB Auto Actions plugin it self set to Public access within CB > Plugin Management as if not then the plugin isn't even loading. The auto action it self should have its Access set to Everybody with User left as Automatic.


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

Facebook Twitter LinkedIn