• 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

Show date difference as "20" instead of "20 years ago"

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

How to set a domain name with php artisan serve

WooCommerce - unset "<product> removed notice…" on cart page

Toggle between a textbox and a select using PHP

Json_Encode not returning html even i try to encode JSON_HEX_QUOT | JSON_HEX_TAG

Creating a config file in PHP

Custom Button next to “ADD TO CART” button of WooCommerce based on Product Type

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

How to set time with DateTime modify?

unable to load your default controller on Codeigniter

Shopify password update using Shopify API

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

"cannot list resources" error from WooCommerce REST API

Reorder attribute dropdown terms in Woocommerce single variable products

About Contact Privacy policy Terms and conditions