• 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

Input and output values for php into the browser?

Redirect to previous page with php

Show date difference as "20" instead of "20 years ago"

How to increase the PHP upload limits [duplicate]

Can we define variables in `.tpl` files?

shell errors running php exec

301 Redirect to remove query string on homepage only

Laravel php artisan serve to mimic HTTPS

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

Popup Window and PHP form

Transform array, set each array element with parent key php

Get sql.h error on MacOS 12 (Monterey) sqsrv and pdo_sqsrv drive installation

Woocommerce redirect after add-to-cart error

Dynamic table in HTML using MySQL and php

No result using makeStyles Material UI in react 18

About Contact Privacy policy Terms and conditions