• 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 downgrade or install a specific version of Composer?

PDOException: PDO::__construct(): php_network_getaddresses: getaddrinfo failed: no such host known

how to search for a file with php

Substitute integers and dots with regex [duplicate]

Smarty: undefined extension class 'Smarty_Internal_Method_Get_Template_Vars'

Filter WooCommerce related products by Polylang language

Unsure why I am getting: Number of variables doesn't match number of parameters in prepared statement

Open a popup box after receiving result from ajax

Required field only if another field has a value, must be empty otherwise

Natural ORDER in Laravel Eloquent ORM

Laravel multi auth - Authentication user provider [] is not defined

Laravel MSSQL Server Connection not working

Dropdown with current value from Mysql

display WooCommerce “Add to cart” button with short-code [add_to_cart ] dynamically

Cache clear probem in Larave

About Contact Privacy policy Terms and conditions