• 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 get array values using foreach in laravel

sqlsrv_num_rows() expects parameter 1 to be resource, boolean given

Store multiple fields in JSON column (Nova CMS)

passwordless LDAP login and get user information using Kerberos ticket in PHP

HTML + PHP + PHPMAILER

printing all running session variable in laravel 5.1

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

PHP usort() order in case of equality

Cannot connect to own websocket server when on secured domain

Boolean assignment operators in PHP

Woocommerce Edit Message "An account is already registered with your email address. Please log in."

How to install ZeroMQ for PHP on an Alpine Linux container?

Adding hreflang tags automatically in WordPress subdirectory multisite

Coinpayments create_transaction "ERROR: Invalid command!"

How to loop a tree array with unknown depth and get array blocks?

About Contact Privacy policy Terms and conditions