• 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

Remove "estimated for {country}" text after tax amount in Woocommerce checkout page

Remove product downloads section in woocommerce email notifications

Check if string contains a value in array [duplicate]

PHP array sort and remove duplicates by two field values

Add bold text and line break into Laravel Notification Email

PHPUnit gives error: Target [IlluminateContractsViewFactory] is not instantiable

Invalid value in field "itemtype" in Google Search Console

retrieve data from database using session

Laravel no logout option from menu after successfull login

add_action() function in wordpress not working [duplicate]

Applying programmatically a coupon to an Order in WooCommerce3

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

Attempt to read property "view" on null when sending password reset email

echo language construct is discouraged. (PHP)

Add rows to Single product Additional information table in WooCommerce 3.6

About Contact Privacy policy Terms and conditions