[SOLVED] In Auto Actions, is onAfterNewUser the Right Event?

3 years 11 months ago #317753 by bascherz
Turns out this weird behavior I reported has to do with how I've been testing my code. I would first register the new user ONE TIME, but then after that, to repeatedly generate the aforementioned sequence of events, I would just set both Confirmed and Approved to No in the site back end user profile and then click the confirmation email link and re-approve the user in the front end. Apparently, this is NOT equivalent to starting all over with a new registration request since, when I do that, my update query works and the profile field values stick.

So this is an interesting thing to note when testing these events both in CB Auto-Actions and also in custom plugins. Now I know. :)

______________________
Bruce S - Vienna, VA

Please Log in to join the conversation.

3 years 11 months ago #317773 by krileon
For that you'd need to also act on onAfterUserApproval, but that trigger will cause a user ->store if the user account is blocked (should be unconfirmed, unapproved, and blocked to mimic new registration state). The user store would cause your changes in a direct database query to be lost unless the user object is also updated (which a field action does). The user object is the first variable of that trigger so your custom plugin just needs to be sure to also set the new value in the user object in addition to the query. Alternatively you can act on onUserActive which is fired after the user store caused by the above situation.


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.

3 years 11 months ago #317781 by bascherz
BINGO!

The onUserActive event was exactly what I was looking for! This actually eliminates the need to have individual trigger registrations and methods in my plugin for each of onAfterUserRegistration, onAfterUserConfirm, and onAfterUserApproval triggers and having to check how user registration is configured in each of those methods. This single trigger seems to fire at the end of that sequence no matter how it is configured in CB Configuration.

THANK YOU VERY MUCH, KYLE! You are awesome! :)

Bruce

______________________
Bruce S - Vienna, VA
The following user(s) said Thank You: krileon

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.207 seconds

Facebook Twitter LinkedIn