• 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

Query Optimization, changing the queries in the loop into a single processing query

Warning: mysqli_stmt::bind_param(): Number of elements in type definition string doesn't match number of bind variables 11 [closed]

How should I get started using PHPUnit as a testing framework for a bunch of functions and classes I have already made?

Reload parent page after submit in iframe

Magento 2 - How to add new block to admin panel in product page?

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

Smarty if isset

Detect a fetch request in PHP

How to add a sidebar to Woocommerce Shop Page?

How can I remove the "Advanced" panel of all blocks in WordPress block editor?

WHM Enabling mod_rewrite

Using Associative arrays

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

401 Unauthorized only occurring on some pages in Laravel 8

Pagekite error: FAIL: localhost:8080 is down

About Contact Privacy policy Terms and conditions