• 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

Mobile browsers are adding .html to filename on download

php echo xml documents with header

Popup Window and PHP form

PHP cURL (SSL certificate problem: self signed certificate in certificate chain)

No result using makeStyles Material UI in react 18

Edit product hook WooCommerce

php script to delete files older than 24 hrs, deletes all files

Where do I need to place a hook for phpunit?

Laravel php artisan serve to mimic HTTPS

How to KeyBy where multiple items have the same key

PHP Include for HTML?

Display a product custom field only in WooCommerce Admin single orders

How can I format this number correctly using PHP?

How to create a cookie to store the timestamp of when a page is first loaded with php

jQuery Ajax Post with data

About Contact Privacy policy Terms and conditions