• 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

image source not readable

How to update array value in Laravel

How to debug in WooCommerce 3+

How to use $this->session->set_userdata in codeigniter

jwt decode throws Invalid argument supplied for foreach() on php-jwt and codeignitor 4

Warning: sqlite_query() expects parameter 1 to be resource, string given

HTML and PHP in one file

Show only featured products in Woocommerce shop page

TesseractOCR not working for Laravel

Display specific shipping method if woocommerce product has specific acf field value

Twig - How to check if variable is a number / integer

PHP Deprecated issue when running artisan command

Get latest Tweets - What API

How to get page number on dompdf PDF when using "view"

php curl requesting twice

About Contact Privacy policy Terms and conditions