In Revo, how do I stop the processing of the next system event?
<?php
// This prevents anyone from deleting a user in the manager, even if they have permissions set to.
// $user
$eventName = $modx->event->name;
switch($eventName) {
case 'OnUserBeforeRemove':
$my_error = 'Please don\'t remove users here.';
return $modx->error->failure( $my_error );
$modx->event->_output = false;
break;
}
return;
i.e. - How do I prevent the user from being deleted, using a Plugin? I’ve tried using the above, but it doesn’t prevent the user from being deleted.
You may or may not want to use the code I write. It's probably all against the syntax rules of php and MODx.
Carpet Cleaning
-
MODX Staff
- 10,725 Posts
I believe you want OnBeforeUserFormDelete, which will allow you to set the output() to a message from the plugin. If a message is received it is handled as a failure.
BTW, if your plugin is only tied to one event, there’s no need to check the name or use a switch statement.
OpenGeek,
Thank you. I got it so it doesn’t delete the user. How do I actually get my error message to appear now?
I’ve tried looking at this thread, but couldn’t get any output.
http://modxcms.com/forums/index.php?topic=51253.0
<?php
// This prevents anyone from deleting a user in the manager, even if they have permissions set to.
$eventName = $modx->event->name;
switch($eventName) {
case 'OnBeforeUserFormDelete':
$my_error = 'Please don\'t remove users here.';
$modx->error->output( $my_error );
break;
}
return;
BobRay,
Thanks for the pointer. I sometimes don’t think about stuff like that.
You may or may not want to use the code I write. It's probably all against the syntax rules of php and MODx.
Carpet Cleaning
-
MODX Staff
- 10,725 Posts
I think the ability to stop processing was recently added to that event for the 2.1 releases. If you are using 2.0.x this is not supported unfortunately.
What I have above stops the processing (the user doesn’t get deleted) in 2.0.8. But how do I output an error message? Is it different for each System Event or do only certain System Events allow output?
An error message appears when I set the permission delete_user to off. "Permission denied!"
You may or may not want to use the code I write. It's probably all against the syntax rules of php and MODx.
Carpet Cleaning