• 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

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

How to prevent phpmailer sending embedded image as an attachment on Gmail?

How to make dot match newline characters using regular expressions

laravel automatically deletes server.php on php artisan serve

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

Problems getting instance of UploadedFile in Yii2

Smarty if isset

how to check version of codeigniter framework?

Add rows to Single product Additional information table in WooCommerce 3.6

Adding the custom page with add_menu_page function on Wordpress

Reorder attribute dropdown terms in Woocommerce single variable products

How can I get user id from session in javascript?

Yoast SEO (WordPress Plugin) - Get plugin generated data manually

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

PHP Startup: Unable to load dynamic library 'openssl' in Ubuntu

About Contact Privacy policy Terms and conditions