• Categories
    • PHP
    • phpMyAdmin
    • PHPMailer
    • FFMpeg
    • PHPEXcel
    • PHPDoc
    • PHPUnit
    • CakePHP
    • CakePHP 2.0
    • Cake PHP 2.1
    • CakePHP Model
    • Facebook PHP SDK
    • composer-php
    • PHP 7
    • PHP GD
    All Categories
  • About

WooCommerce Subscriptions: Remove role on cancelled subscription

phpwordpresswoocommercehook-woocommercewoocommerce-subscriptions


PHP Snippet 1:

add_action('woocommerce_subscription_status_cancelled', 'wcs_maybe_remove_role', 10, 1);

function wcs_maybe_remove_role($subscription) {
    $user_id = $subscription->get_user_id();
    $user = new WP_User($user_id);
    $user->remove_role('silver');
    $user->remove_role('gold');
}

Related Snippets

How to read laravel_session cookies saved in cookie memory of browser in client side?

Update Order custom Field value with WooCommerce REST API

Performance of foreach, array_map with lambda and array_map with static function

How to retrieve Active Directory group policy maximum password age using LDAP

Appending data to an anchor tag

What will the best solution for this multiple optional filter?

PHP mail function is sending blank message body

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null

unable to load your default controller on Codeigniter

Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given [duplicate]

Can I use a WooCommerce function without any WooCommerce page?

Show only featured products in Woocommerce shop page

GRPC installed successfully on ubuntu but php is looking for it in another folder

Correct way to use LIKE '%{$var}%' with prepared statements?

Add custom text under order details on WooCommerce My account view order pages

About Contact Privacy policy Terms and conditions