Is it possible to prevent Joomla from deleting users with a user plugin? We need the user profile to be disabled, but never deleted.

I've been tinkering with onUserBeforeDelete, but the docs refer back to v1.5, so I'm not sure that I'm even approaching it the right way to "cancel the event".

  • 1
    What Jordan said, just put your custom joomla user plugin in an ordering BEFORE the default joomla user plugin so that it takes precedence. Jun 20, 2014 at 15:47

1 Answer 1


In the plugin, force a redirect back to the page the delete button is on.

public function onUserBeforeDelete($user)
    $app = JFactory::getApplication();
    //possibly set an error message
    JError::raiseWarning( 100, 'Warning: Cannot delete user profile' );

That example can be adjusted, but it should work to just simply stop the user, you could go into some mysql queries to "disable" the user instead, to make it seem like it was disabled rather then just setting an error as well.


The link there was last edited less then a year ago, so I highly doubt that onUserBeforeDelete had any major changes.

  • I'm assuming this would be the code in MY plugin, and the redirect/jexit would halt any further Joomla execution (i.e. the deletion itself), correct?
    – GDP
    Jun 19, 2014 at 19:50
  • Yes, this is the most "supported" way to do it as messing the the actual delete function itself would require a core override. Plugins are very easy to make, and that example I linked should have all the files you need to make a simple plugin. Jun 19, 2014 at 19:54
  • I love plugins....just have never had to prevent an event from firing from subsequent plugins. Though this technically, isn't doing that, but accomplishes it with the redirect. Do you know if it is possible to actually "stop" following plugins from firing on the same event and let the page continue as it was?
    – GDP
    Jun 19, 2014 at 20:03
  • Well the delete function is not from a plugin, its in libraries/joomla/user/user.php and it uses JTable to delete the user, so there really is not an option you can add in the plugin to prevent it from doing that, as you do not have access to the JUser instance to change any values in it. Actually, if you use onUserBeforeDelete user to override JTable to not do anything other then return "true" then disable the override in onUserAfterDelete you "might" be able to do that. Jun 19, 2014 at 20:26
  • 1
    I can't tell whats depreciated and not anymore lol, thanks. docs.joomla.org/Display_error_messages_and_notices some other people may confuse it as well, its not labeled in the documentation. Jun 20, 2014 at 16:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.