onAfterDeleteUser trigger

8 years 6 months ago - 8 years 6 months ago #272192 by cpackert
onAfterDeleteUser trigger was created by cpackert
I'm writing a plugin for CB that fires on user updates, creations, and deletions. My code is firing okay for updates and deletions using "onAfterUserUpdate"/"onAfterUpdateUser" and "onAFterNewUser"/"onAfterUserRegistration".

I can't get my code to fire for a user deletion though. I'm using this registration line:

$_PLUGINS->registerFunction( 'onAfterDeleteUser', 'deleteuser' );

function deleteuser(&$user,&$cbUser) {
$to = 'me@someplace.com';
$subject = 'User Deleted';
$message = 'Test message to ensure trigger is firing: Success';
mail($to, $subject, $message);
return true;
}

I then go to the Community Builder User Management page, select a user, and click Delete. But the trigger does not appear to be firing. Again, everything is working in almost the same manner for user creation/updating.

Thanks!

Please Log in to join the conversation.

8 years 6 months ago #272215 by krileon
Replied by krileon on topic onAfterDeleteUser trigger
Why not use CB Auto Actions? It comes with an Email action that you can use on the after delete user trigger. No custom coding needed. We can not advice you on custom coding as a snippet doesn't give any idea if the plugin is even functional.


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.

8 years 6 months ago #272224 by cpackert
Replied by cpackert on topic onAfterDeleteUser trigger
Sending an email was just a way of making sure it worked.

My question is simply this: when does the onAfterDeleteUser action fire? Is it when a user is deleted manually through the User Management page?

Please Log in to join the conversation.

8 years 6 months ago #272255 by c_schmitz
Replied by c_schmitz on topic onAfterDeleteUser trigger
(The trigger documentation should be updated with this information, IMO! Now it's just a list of the triggers, without any comments.)

Please Log in to join the conversation.

8 years 6 months ago #272286 by krileon
Replied by krileon on topic onAfterDeleteUser trigger
It's fired when a user is deleted within CB > User Management or when ->delete() is called on a user object.


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.

8 years 6 months ago #272440 by cpackert
Replied by cpackert on topic onAfterDeleteUser trigger

krileon wrote: It's fired when a user is deleted within CB > User Management or when ->delete() is called on a user object.


Thank you Krileon!

c_schmitz wrote: (The trigger documentation should be updated with this information, IMO! Now it's just a list of the triggers, without any comments.)


I second that c_schmitz

I discovered that I had defined my function incrorectly, I need to be more careful about which variables are actually passed by the triggers. This is the wrong way to setup the trigger function for onBeforeDeleteUser:

function deletetheuser(&$user,&$cbUser) {}

This is the right way:

function deletetheuser($user) {}

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.242 seconds

Facebook Twitter LinkedIn