Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call to undefined function wp_delete_user()

Tags:

wordpress

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.

like image 896
Esteban S Avatar asked May 06 '16 20:05

Esteban S


2 Answers

At first, please ask WP questions at: Wordpress.Stackexchange.com


p.s.: before that line insert:

require_once(ABSPATH.'wp-admin/includes/user.php');
like image 168
T.Todua Avatar answered Nov 11 '22 04:11

T.Todua


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' );

like image 31
imfromio Avatar answered Nov 11 '22 04:11

imfromio