• 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

Insert a DIV after the 6th product only once in WooCommerce category archives

How to create a individual template for page or post in custom plugin?

Adding custom body class to the custom archive pages

laravel 5.6 bulk inserting json data

Ajax GET request fails in laravel 8

How to submit a form when page loads using JavaScript?

How to put php code inside opening and closing shortcodes

WordPress - Dynamically add user ID to the end of a URL

PHP Imap , php 7.4.3 on mac osx catalina

how to identify the web server name of remote host

JQuery content editable div and text box on submit not sending POST

PHP: Insert marker every 3 iterations

Edit product hook WooCommerce

Class AppHttpControllersUserController Does Not Exist

GuzzleHttp Hangs When Using Localhost

About Contact Privacy policy Terms and conditions