• 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 categories with all childs derived from parent category

Correct way to use LIKE '%{$var}%' with prepared statements?

How to use a PHP MVC Controller, one thats invoked by calling a URL, to call and execute more than one function? [duplicate]

php 7 php.ini upload_max_filesize not working

Show only featured products in Woocommerce shop page

Boolean assignment operators in PHP

How can I get a div content in php

Best way to scrolldown onpageload

Query Optimization, changing the queries in the loop into a single processing query

Add rows to Single product Additional information table in WooCommerce 3.6

Call authenticate manually in router middleware

Display a success custom notice after Placing an Order in WooCommerce

PHP rotate matrix counter-clockwise

Hi, I am making a contact form thingy, and my php isn't working any reason why?

Detect emoticons in string

About Contact Privacy policy Terms and conditions