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.
p.s.: before that line insert:
require_once(ABSPATH.'wp-admin/includes/user.php');
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' );
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With