• 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

Custom add to cart button URL for specific product in WooCommerce?

Use Python plotly chart in PHP

How do I do HTTP basic authentication using Guzzle?

Custom add to cart button URL for specific product in WooCommerce?

Docker & Laravel : configure: error: Package requirements (oniguruma) were not met

OAuth2 Token PHP

Inserting Country Selection into MySQL PHP [duplicate]

PHP Get value from JSON [duplicate]

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

Detect if PHP session exists

Converting alphabet letter to alphabet position in PHP [duplicate]

Only on Firefox "Loading failed for the <script> with source"

How to implement placeholder in a php file for moodle plugin?

Manage independently the decimal number of the price of each product [duplicate]

error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure

About Contact Privacy policy Terms and conditions