• 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

Only on Firefox "Loading failed for the <script> with source"

Applying programmatically a coupon to an Order in WooCommerce3

Add 2 Webcam in one page with WebcamJS

How do I do HTTP basic authentication using Guzzle?

PHP and WebView - Cookie doesn't are the same

Can we define variables in `.tpl` files?

Combining a describing and one array with data

file_put_content...fail to open stream:Permission denied in Laravel 5

woocommerce get_order_report_data to show order_item_id

How to assert parameter attribute sub-structures in PHPUnit mock call expectations

Minimum order amount except for specific shipping method in WooCommerce

How to fix this error : Ask your hosting provider to use PHP 7.2.5 or higher for both HTTP and CLI?

Hide email address with stars (*)

Apply filter array/return terms

Get number of working days between two dates in PHP [duplicate]

About Contact Privacy policy Terms and conditions