Skip to content

Instantly share code, notes, and snippets.

@emzo
Created July 5, 2012 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emzo/3052518 to your computer and use it in GitHub Desktop.
Save emzo/3052518 to your computer and use it in GitHub Desktop.
WP Protect user account from deletion
add_action( 'delete_user', 'dont_delete_user' );
function dont_delete_user( $id ) {
$dont_delete_ids = array( 1, 2, 3, 4 ); // protected user IDs
if ( in_array( $id, $dont_delete_ids ) )
wp_die( 'You cannot delete this user account.' );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment