• 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

Magento Installation SQLSTATE[HY000] [2002] No such file or directory error

php 7 php.ini upload_max_filesize not working

Hide specific products from unlogged users based in product category in WooCommerce

javascript html popup window

Laravel Route issues with Route order in web.php

Laravel Pagination links() not working

Laravel 5 session not persisting after user is logged in

Select option menu read from database and use it's values

Xdebug 3 not showing in phpinfo on m1 Monterey

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

Symfony 4: "Autowire: you should configure its value explicitly."

Display specific shipping method if woocommerce product has specific acf field value

SMTP "Error: DATA not accepted from server!" Opencart 2.3 on InMotionHosting

wordpress function breaks wp-admin

Adding multiple items to WooCommerce cart at once

About Contact Privacy policy Terms and conditions