• 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

Invalid value in field "itemtype" in Google Search Console

How to Generate PDF invoice to XML format using mPDF

virtctl works when executed via command line but not from php exec()

Install mysql client in docker image

Entity provider not working in security.yml php symfony3.4 ({"code":401,"message":"bad credentials"}.)

Query Optimization, changing the queries in the loop into a single processing query

Increase value by 1 on button click

Laravel php artisan serve to mimic HTTPS

Laravel Nova, route not found

Mysqli multi query error

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

How to get monthly wise data in laravel

Confirm Leave on External Links in Wordpress

Set quantity minimum, maximum and step at product level in Woocommerce

If you intend you use SMTP, add your SMTP Code after this Line

About Contact Privacy policy Terms and conditions