• 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 add a custom field to all Woocommerce attribute terms using add_action

The sum of the user's points

woocommerce get_order_report_data to show order_item_id

How to insert Google Adsense Code in PHP script?

How to change product Image when variables are selected in Shop and Archive Pages?

Generate random username based on full name php

advanced custom fields wordpress custom class

How to add a custom field to all Woocommerce attribute terms using add_action

What is PHP's equivalent of JavaScript's "array.every()"?

How to unlink image from folder?

Converting IPv6 to IPv4 address in PHP

add_action() function in wordpress not working [duplicate]

JQuery content editable div and text box on submit not sending POST

oauth-private.key does not exist or is not readable

How Can I Do LIMIT 1, 2 In WP_Query

About Contact Privacy policy Terms and conditions