• 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 to identify whether webp image is static or animated?

php 7 php.ini upload_max_filesize not working

How to Display Data in Yajra Datatables Laravel 7?

The difference when using if statement true === something() vs something() === true [duplicate]

Symfony Make:Migration : The metadata storage is not up to date, please run the sync-metadata-storage command to fix this issue

How to create a cookie to store the timestamp of when a page is first loaded with php

Read users and passwords from a txt file

Make Shipping Method fields Mandatory on Woocommerce checkout page

Laravel Unresolvable dependency resolving [Parameter #0 [ <required> $method ]] in class GuzzleHttpPsr7Request

Modify microseconds of a PHP DateTime object

Comma separated list from array with "and" before last element

Pass a select with mysqli_fetch_row to a table

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Laravel unique validation on multiple columns

What is the difference between client-side and server-side programming?

About Contact Privacy policy Terms and conditions