• 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

Laravel views are showing from cache on one server but works fine on other server

Which is faster php date functions or carbon?

Declaration of OMDb::query(string $statement) must be compatible with PDO::query

PHP rotate matrix counter-clockwise

Laravel PackageManifest.php: Undefined index: name

Warning: sqlite_query() expects parameter 1 to be resource, string given

args[max_input] woocommerce if statement confused

Dynamic dropdown Ajax PHP request

Prestashop webservice API creating cart rules

could not find driver Debian SQL Server PHP

Laravel 4 Redirect::back() not going to previous page (refreshing current page)

How to redirect to another page and call a Function there on Angular ng-click

Minimum order amount except for specific shipping method in WooCommerce

Add bold text and line break into Laravel Notification Email

How avoid Moved Permanently The document has moved here

About Contact Privacy policy Terms and conditions