Esteban S
Esteban S

Reputation: 1919

Call to undefined function wp_delete_user()

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

Answers (2)

T.Todua
T.Todua

Reputation: 56487

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


p.s.: before that line insert:

require_once(ABSPATH.'wp-admin/includes/user.php');

Upvotes: 37

imfromio
imfromio

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

Related Questions