• 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

WordPress - Dynamically add user ID to the end of a URL

Set quantity minimum, maximum and step at product level in Woocommerce

woocommerce change position of price

Get all WooCommerce products within own plugin

Add 2 Webcam in one page with WebcamJS

WHM Enabling mod_rewrite

Message: Set sys_temp_dir in your php.ini after installed composer

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

Multiple order by in WooCommerce

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

Warning: mysql_num_rows(): supplied argument is not a valid MySQL result resource [duplicate]

MySQL upgrade causing unexpected results on simple WHERE clauses

Yii2: How to download backup files using spanjeta/yii2-backup?

Display a success custom notice after Placing an Order in WooCommerce

Natural ORDER in Laravel Eloquent ORM

About Contact Privacy policy Terms and conditions