Skip to Content Skip to Menu

🎃 Happy Halloween! Treat yourself with an awesome discount on memberships! Get 20% off now with code SPOOKY-2024!

[SOLVED] custom trigger

11 years 4 weeks ago - 11 years 1 week ago #234744 by iytworldwide
[SOLVED] custom trigger was created by iytworldwide
Hi Kyle,

I want to add a custom trigger into autoaction. I have 3 types of membership types, student, instructor and admin. When a user registered, he has a default membership type role as Student. The user is auto approved but we have a custom field (cb_iytapproved) which is set(approved) by the super user. Now when this value is set as approved I want to fire triggers such as
1. adding user to respective joomla groups based on his/profile
2. creating groupjive group

I see alot of triggers events such as after approval, after login, before login etc. but for this scenario I will need my own trigger event such as onApprovalbyIYT so please let me know is there any documentation available about how to add custom event in the available list of triggers and make it functional.

This event should get fired through CB workflow admin approval/rejection screen. I have to customize that and include pending user check based on the custom field(cb_iytapproved) and not the "approved" field which comes as default check with CB workflow.

Thanks,
Amit Dangwal
Last edit: 11 years 1 week ago by krileon.

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
11 years 4 weeks ago #234767 by krileon
Replied by krileon on topic custom trigger
You can't just add triggers to it. That's not how it functions. There are triggers all throughout CB that can be acted on, which is all CB Auto Actions does (acts on those already existing triggers). They're built into core code. You also can't have a trigger fire for 1 specific field. You need to use a more generic trigger and condition it to your needs.

With that said depending on how you're changing the cb_iytapproved field you should be able to use the after profile update triggers then condition for cb_iytapproved. If you modify the registration approval form then you can probably use onBeforeUserApproval or onAfterUserApproval and condition your custom input using [post_FIELDNAME].


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.

11 years 4 weeks ago #234775 by iytworldwide
Replied by iytworldwide on topic custom trigger
Thanks Kyle for the input. I like the idea. In below statement, I am just confirming whether I understood your direction completely.

1. I should modify the "registration approval form" (which is CB workflow as that the screen from where moderator approves the user). This is a customization change.
2. On CB workflow screen, on clicking accept, the approved value must be set in the required custom field through custom code
3. A post update trigger i.e. onAfterUserApproval must be configured which will read the condition about custom field value and performs the action of adding user to various groups.

I hope this is what you are suggesting. I will try this.

Thanks,
Amit Dangwal

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48473
  • Thanks: 8281
  • Karma: 1443
11 years 4 weeks ago #234780 by krileon
Replied by krileon on topic custom trigger

1. I should modify the "registration approval form" (which is CB workflow as that the screen from where moderator approves the user). This is a customization change.

I suppose you could modify it and add an extra input to it, but you'd also going to want to modify comprofiler.php to have it store the custom value to the users row.

2. On CB workflow screen, on clicking accept, the approved value must be set in the required custom field through custom code

See reply to #1.

3. A post update trigger i.e. onAfterUserApproval must be configured which will read the condition about custom field value and performs the action of adding user to various groups.

Well if you modify comprofiler.php to also handle the storage then you only need onAfterUserApproval to give them the usergroup you're wanting by conditioning your field (don't need to condition from POST in this case).


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.

11 years 4 weeks ago #234783 by iytworldwide
Replied by iytworldwide on topic custom trigger
Thanks Kyle for quick input and the direction. I am going to try this out. I am planning not to touch users table if possible. In CB workflow, I will list the pending approval based on the custom field (and not on the default approved field as that is already approved). I will add a trigger onAfterapproval to set custom field as approved and then other triggers to add user to groups etc. I want to avoid as much customization as possible and use the product features so that in future while upgrading/updating CB my custom changes should not get overwritten.
If this works then fine else I will look for users table changes.

Thanks,
Amit Dangwal

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

11 years 1 week ago #235691 by iytworldwide
Replied by iytworldwide on topic custom trigger
I developed the solution by adding custom trigger "onAfterUserGroupApproved" and "onAfterUserGroupRejected" in CB. I added these trigger in admin.cbautoactions.php. I have further modified CB Workflow to display pending user groups for approval in addition to the existing functionality of displaying pending user approval, ban reports etc. I made a call to trigger event by invoking $_PLUGINS->trigger('onAfterUserGroupApproved'...). In CB auto actions also, these triggers are getting listed and I have configure required action against it. I have tested it and it is working

I got this idea from our discussion of missing trigger "onSaveUserError" in display list www.joomlapolis.com/forum/153-professional-member-support/223071-4289-image-field-error?start=18

I am able to achieve the functionality as mentioned initially in the thread. I have not modified any joomla table(users) for this.
"This event should get fired through CB workflow admin approval/rejection screen. I have to customize that and include pending user check based on the custom field(cb_iytapproved) and not the "approved" field which comes as default check with CB workflow."

You have mentioned "You can't just add triggers to it.". So now, do you see any issue(security, bug, other dependency) as why it cannot be done in this way through custom trigger? I am building a solution and I am concerned about the approach stability thats why I am asking. Please do not take me wrong.

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

Moderators: beatnantkrileon
Powered by Kunena Forum