• 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 do I pass the dynamic output of a php variable or php function to a CSS variable?

Why i get wrong output for html markdown?

Not able to override collapsible.js in magento 2

How do I loop through an MS SQL database with VB.NET?

Laravel implode array items to new lines

how to prevent float variables displaying as scientific notation when printing [duplicate]

args[max_input] woocommerce if statement confused

Laravel Livewire: jQuery not working in child component loaded via @if statement

PHP: PDO + CSV export not downloading (headers issue?)

Laravel UUID generation

Don't show recurring price for WooCommerce subscriptions worth 0$

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

Use same method for inertia response and json response Laravel Jetstream

How to Install Composer Require doctrine/dbal

PHP array stringify

About Contact Privacy policy Terms and conditions