• 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

Change user role if checkout custom checkbox is checked in WooCommerce

Access denied for user 'homestead'@'localhost' (using password: YES)

Laravel excel maatwebsite 3.1 import, date column in excel cell returns as unknown format number. How to solve this?

woocommerce get_order_report_data to show order_item_id

Creating Combinations of Elements

how to youtube api data to print in toolset metabox using a button click before save-post

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

PHP how to detect if running on arm64 cpu?

Call to a member function fetch_field() on a non-object MySQLiDB

laravel sanctum Route [login] not defined

Dynamic table in HTML using MySQL and php

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

WordPress ACFNotice: get_field() - We've detected one or more calls to retrieve ACF field values before ACF has been initialized

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

How to display MySQL table using php and edit it in a web browser

About Contact Privacy policy Terms and conditions