• 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 Database Strict Mode

Wordpress wpdb->delete issue

Which is faster php date functions or carbon?

PHP how to detect if running on arm64 cpu?

PHP/HTML: Creating A SubMenu

Update Order custom Field value with WooCommerce REST API

PHP to search within txt file and echo the whole line

How to reset Laravel AuthManager/guards in between API calls in tests?

How to install php_imagick on wamp64

Laravel whole batch is cancelled if one Job fails

laravel automatically deletes server.php on php artisan serve

CONCAT columns with Laravel 5 eloquent

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

Webscraping Symfony/Panther: Can't get HTML

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

About Contact Privacy policy Terms and conditions