• 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

Get WooCommerce products from specific category

Laravel 5.2: Unable to locate factory with name [default]

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

oauth-private.key does not exist or is not readable

PHP array_filter with arguments

PHP: Print caught exception like Xdebug

Webscraping Symfony/Panther: Can't get HTML

woocommerce change position of price

How to skip cart page on woocomerce for certain products only?

Get orders by date and status woocommerce

php curl_exec() Connection refused when retrieving a remote image

Unable to get password for the instance created from AMI

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Array to string conversion

Can't find vendor/autoload.php for Ratchet

About Contact Privacy policy Terms and conditions