Change role of all wp users that made a purchase in the past?

[ad_1]

Hi, I would like to delete all users except users that have any log or contact with edd.

Registered Spam bots are also in subscriber role same a to many customers with expired licenses etc.

How can I change role of all add customers at once?

I tried this function that I found on github but it didn’t change anything on users.

add_filter( 'edd_insert_user_args', 'wpb_edd_customer_user_role', 10, 2 );

if( !function_exists('wpb_edd_customer_user_role') ):
function wpb_edd_customer_user_role( $user_args, $user_data ) {
$cart_price = edd_get_cart_total();

if( floatval($cart_price) <= 0 ){
$user_args['role'] = 'free_customer';
}else {
$user_args['role'] = 'premium_customer';
}

return $user_args;
}

endif;

If you have any idea please let me know or maybe a sql command that does the same job.

  • This topic was modified 53 minutes ago by gjyshi.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer