• 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 validate tin and cst using PHP?

generating a random code in php?

How do I loop through an MS SQL database with VB.NET?

Is it possible to re-use an array taken from PHP via JSON in a $.ajax function?

Adding the custom page with add_menu_page function on Wordpress

How to debug in WooCommerce 3+

Any AWS EB Laravel route getting 404 Not Found nginx/1.16.1

PHP Startup Unable to load dynamic library /usr/lib/php/20151012/php_mysqli.dll

Using if(isset($_POST['submit'])) to not display echo when script is open is not working

How to install PHP composer inside a docker container

Add customer email and phone in "Order" column to admin orders list on Woocommerce

WHM Enabling mod_rewrite

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

Yii2 select2 database exception number of bound variables does not match number of tokens

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

About Contact Privacy policy Terms and conditions