I am writing the following code to do some cleanup before deleting a user via the admin area
function delete_user_custom_data ($user_id) {
$result = do_some_cleanp($user_id); // The do_some_cleanp() function returns true on success and false on failure
if ($result == false) {
?>
<div class="notice notice-warning is-dismissible">
<p>There was a problem</p>
</div>
<?php
}
}
add_action('delete_user', 'delete_user_custom_data');
What I like to do is prevent the deletion of the user from running if the code in the ‘delete_user’ action function was not successful. How do I do that?
Thanks.