Welcome!
You need to include 'wp-admin/includes/user.php'
before calling wp_delete_user
function. The reason is, it is an admin functionality and it is not available everywhere in code.
In Your case, just put the following line of code at the very beginning of the function.
require_once ABSPATH . 'wp-admin/includes/user.php';
Related Posts:
- Problem with Woocommerce REST API Authentication
- using woocommerce_template_single_add_to_cart in shop-loop – javascript issues [closed]
- Woocommerce hook run after an Order been created through REST API
- Woocommerce api: create product with images – bad request
- Woocommerce: hook action/filter I could use to add variation id and price with each attribute opt on WooCommerce Rest api
- WooCommerce REST API AJAX Auth – 401 response
- Looping through and combining calls to Woocommerce REST API
- Need to forward Data from WooCommerce Webhook sent to same site WordPress REST API custom endpoint
- How to correctly add Javascript in functions.php
- How to loop through JSON data in wordpress WP REST API
- Display sorting options dropdown when using WooCommerce product category shortcode
- How to make an meta_query optional?
- How to remove “out of stock” variation options from size dropdown in woocommerce?
- Woocommerce: How to override core functions in functions.php?
- wordpress custom endpoint multiple params
- Get WooCommerce shipping methods programmatically
- Add a custom text field to WooCommerce admin product data “Variations”
- Translating add to cart woocommerce button [closed]
- Add attribute / custom attribute to product in woocommerce
- How do I fetch all comments per post via WP REST API?
- Help with some php math in WordPress
- How do I display a user’s previous orders as a select box option on a product?
- combine Code 1 with Code 2
- Make the first item as default on Woocommerce product category items list
- Adding nofollow to a PHP generated Nav
- Automated Cart Update With Alert Box Each Time
- Two Different Links for Same Product – WooCommerce [closed]
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- dividing sub-categories by parent category – WordPress
- Show prices with tax in Woocommerce Mini Cart [closed]
- Problem with custom plugin using AJAX to pull info from php file
- Reload part of checkout on changed shipping method
- Woocommerce related product text
- Is it possible to intercept all ajax requests and get the parameters and the returns?
- Function works when I don’t login to WordPress but when I login then it doesn’t work
- I want to add custom add to cart link [closed]
- How to make products with no cost in WooCommerce
- Incorrect amount of posts returned when filtering related Woo products by custom taxonomy
- Delete taxonomy and delete all post related it
- How to remove coupon dropdown feature
- How to set a template with wp_insert_post
- Add html link in functions.php files of the theme
- Multiple requests external data api dynamic block gutenberg
- Add product to cart for user – WC()->cart->add_to_cart [closed]
- Can a plugin redirect product page based on IF condition?
- Seo Friendly Filter URLs
- Remove page title in product page using a function
- woocommerce specific quantities for product
- woocommerce related product title length
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- woocommerce wc_create_order(); is creating multiple orders instead of one?
- WordPress site with embedded menu – gives You don’t have permission to access /wp-content/themes/xxx/taxonomy-redirect.php on this server
- Woocommerce custom Plugin in wordpress [closed]
- How to separate product payment and shipping payment in WooCommerce checkout? [closed]
- Output product category link from WP_Query
- How to get woocommerce orders with get_posts method in a shortcode
- How to restrict shipping zone in a specific interval time
- Hide specific product from Woocommerce if the logged-in user has already enrolled into the course
- Variation prices breakdown only for single product page
- Woocommerce disable order item link (backend) [closed]
- Set all WooCommerce Products to Simple, Virtual & Downloadable
- Undefined array key 0 wp-includes/capabilities.php on line 76
- How do I know if the user is a customer?
- product_type_options get saved value [closed]
- I want to fusion the product columns in email table order
- WooCommerce is_product_category() not working
- Best way to use variables in multiple functions?
- Display all categories including sub categories under a list ul
- How do I programmatically add ‘reviews_allowed’ to WooCommerce product?
- Add to cart quantity dynamic
- Adding new divs with custom classes to products on WooCommerce shop page [closed]
- Get product price in a different currency using WooCommerce Currency Switcher
- Adding product permalink on admin order page throwing error
- How to override WooCommerce Order Item Meta with data from Cart?
- Woocommerce textarea format ignored
- How to get total gross revenue for current month in the woocommerce dashboard status widget
- Add custom attribute to product’s HTML to woocommerce cart page
- Change WooCommerce template for PDF – access to custom field
- How can i style “echo apply_filters”
- Get all woocommerce product names with price and show using core php
- Add custom ID attribute to all woocommerce products on archive pages
- How to properly create multiple conditions to redirect users roles to different pages
- How to limit functionality of a woocommerce plugin to only certain user role?
- How can i put php code on the wordpress page?
- Use PHP code in Menu Admin Section
- How to detect if a revision was made by woocommerce or wordpress?
- How do I prevent a folder from reappearing in my home directory?
- jQuery doesn’t work in my php snippet
- Use WP_Query Data In Cookie
- How to add custom checkout field in user details mail template
- Add specific phrase after every product title including the discounted price? [closed]
- Display Sale Price Before Regular Price (WooCommerce)
- Setting WooCommerce currency programmatically
- WooCommerce – Show ‘Sales’ badge on variable products where only some variations have sales price [closed]
- How to create a container in php then customise it in CSS
- Grabbing value of input field inside of array
- How to set variable to specific field when querying
- WooCommerce Checkout Cart [closed]
- WordPress REST API – Custom field not added to pages
- Woocommerce – add tracking code to another email template