• 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

If action is on a different page do I use fwrite function

Don't show recurring price for WooCommerce subscriptions worth 0$

Doctrine ORM: Excluding Records Based on Values of Nested Relationships

How to keep value of selected value after form submission?

PHP SoapClient: set a namespace without prefix

Best way to scrolldown onpageload

Search for array row with specific column value and return another value from qualifying row

Update Order custom Field value with WooCommerce REST API

Increase value by 1 on button click

Laravel PackageManifest.php: Undefined index: name

Shortcode or PHP inside a shortcode in Wordpress

Last order would be re-order in wooCommerce. How is it possible?

Correct way to use LIKE '%{$var}%' with prepared statements?

Add custom text under order details on WooCommerce My account view order pages

Create tags in laravel post publishing

About Contact Privacy policy Terms and conditions