• 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

Woocommerce Edit Message "An account is already registered with your email address. Please log in."

500 Internal Server Error on Ajax request. Not sure the origin of the problem

Too few arguments to function PendingResourceRegistration::name(),1 passed in C:xampphtdocsproject outesweb.php on line 18 and exactly 2 expected

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Prestashop webservice API creating cart rules

Convert date and time to Jalali in Laravel

Add customer email and phone in "Order" column to admin orders list on Woocommerce

PHP block shortcut in Visual Studio Code

Custom add to cart button URL for specific product in WooCommerce?

How to get median and quartiles/percentiles of an array in JavaScript (or PHP)?

Updating and Synchronizing Woocommerce Subscriptions to Custom Date

MOODLE: What does it mean to aggregate h5p assets?

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

How to run a shell as root from php (apache)

About Contact Privacy policy Terms and conditions