• 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

Laravel insert dynamic input values with radio button

Woocommerce Checkout - Add conditional field required if one field is filled

PHP - installing Xdebug on Mac with XAMPP (Unix File)

How to remove from a multidimensional array all duplicate elements including the original?

Display the WooCommerce product price inside a custom function

Display a product custom field only in WooCommerce Admin single orders

Adding hreflang tags automatically in WordPress subdirectory multisite

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Call to undefined function openssl_decrypt

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

How to add automatically collapse/expand in content wordpress (single.php)?

PHP password_verify

Adding custom body class to the custom archive pages

PHP | "The requested PHP extension bcmath is missing from your system."

About Contact Privacy policy Terms and conditions