• 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

Problem with fetching data from database in Laravel

Get latest Tweets - What API

Laravel Nova Dependency Container what are the allowed resource properties other than id in dependsOn

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

Split comma separated value from table column into rows using mysql?

Attempted to call an undefined method named "get" of class "MailController"

Center point of multiple gps coordinates with php

laravel 5.6 bulk inserting json data

onKeyUp event calculation not working on the following rows from php generated forms except the first one

Open a popup box after receiving result from ajax

401 Unauthorized only occurring on some pages in Laravel 8

Transform array, set each array element with parent key php

Star and Half Star Rating in Laravel

Invalid value in field "itemtype" in Google Search Console

Timber: Single post pagination does not work (wp_link_pages)

About Contact Privacy policy Terms and conditions