Reputation: 1919
Hello I am new to Wordpress and PHP and I am trying to delete an user in a function in a plugin.
wp_delete_user( $user->ID );
Everything is working well but when I try to use wp_delete_user i get the following error:
Call to undefined function wp_delete_user() in /homepages/6/d480314532/htdocs/wsb7416187601/zisteau_web/wp-content/plugins/patreon-wordpress-master/classes/patreon_wordpress.php on line 135
This function is located in wp-includes/user.php. Are there any way to import this funtionality to use it there?
Thanks.
Upvotes: 15
Views: 11561
Reputation: 56487
p.s.: before that line insert:
require_once(ABSPATH.'wp-admin/includes/user.php');
Upvotes: 37
Reputation: 31
I found this in a Google search and wanted to add this for anyone looking for a solution when using WordPress multisite. Instead of loading wp-admin/includes/user.php, you'll need to load wp-admin/includes/ms.php like:
require_once( ABSPATH . 'wp-admin/includes/ms.php' );
Upvotes: 3