• 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

How to get variable from JavaScript to PHP [duplicate]

XAMPP/SQLSRV: Unable to find Sqlsrv in PHPINFO(); - errors coming from connection

oauth-private.key does not exist or is not readable

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

Malformed MIME header error in Symfony 5.3

How to load Codeigniter 4 lang file into an array variable

json_encode turns array into an object

Display the WooCommerce product price inside a custom function

Laravel Carbon throws error The format separator does not match

Add a custom text for a particular product on specific email notification in Woocommerce

Laravel Command Schedule Not Working Properly

Laravel 5 issue with wherePivot

How to convert time from one timezone to another in PHP

How to upload mpdf file after generating to s3 bucket in php

PHP AWS Cognito 'Error executing "SignUp" : ResourceNotFoundException : User pool client XXXX does not exist

About Contact Privacy policy Terms and conditions