admin管理员组文章数量:1406926
Here is my code:
function woo_delete_customer(){
$customer = new WC_Customer(get_current_user_id());
$val = $customer -> delete();
if($val){
$customer -> save();
$data = [];
$data['Status'] = 'Customer was successfully deleted';
return new WP_REST_Response( $data, 200 );
}
else{
new WP_Error(
'woo_deleting_problems',
'Can\'t delete customer!',
array(
'status' => 403,
)
);
}
}
And here is my logs:
2019-11-16T05:29:23+00:00 CRITICAL Call to undefined function wp_delete_user() in /home/test/public_html/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store.php on line 235
Please help me!((
Here is my code:
function woo_delete_customer(){
$customer = new WC_Customer(get_current_user_id());
$val = $customer -> delete();
if($val){
$customer -> save();
$data = [];
$data['Status'] = 'Customer was successfully deleted';
return new WP_REST_Response( $data, 200 );
}
else{
new WP_Error(
'woo_deleting_problems',
'Can\'t delete customer!',
array(
'status' => 403,
)
);
}
}
And here is my logs:
2019-11-16T05:29:23+00:00 CRITICAL Call to undefined function wp_delete_user() in /home/test/public_html/wp-content/plugins/woocommerce/includes/data-stores/class-wc-customer-data-store.php on line 235
Please help me!((
Share Improve this question asked Nov 16, 2019 at 5:52 Atamyrat BabayevAtamyrat Babayev 1134 bronze badges1 Answer
Reset to default 1Welcome!
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';
本文标签: phpWCCustomer delete function returns error
版权声明:本文标题:php - WC_Customer delete function returns error 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744999809a2636906.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论