Delete / remove user role in Woocommerce

          
add_action('init', function() { // Replace 'your_custom_role' with the actual role slug you want to remove if (get_role('your_custom_role')) { remove_role('your_custom_role'); } }); //------------ or reassign the role add_action('init', function() { $old_role = 'your_custom_role'; $new_role = 'customer'; // or any other role // Reassign users $users = get_users(['role' => $old_role]); foreach ($users as $user) { $user->set_role($new_role); } // Remove the old role if (get_role($old_role)) { remove_role($old_role); } });
Was this helpful?
YesNo

Leave a Reply