To use WordPress's wp_delete_user function in your theme or plugin

Just add this line before calling wp_delete_user function:

require_once(ABSPATH.'wp-admin/includes/user.php');
wp_delete_user($user->ID);