• 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

Class AppHttpControllersUserController Does Not Exist

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

PHP: How to quickly split a key=value file into associative array

Query Optimization, changing the queries in the loop into a single processing query

Apply filter array/return terms

Add restriction to WooCommerce coupons by allowed user ID

How to get AJAX to post on second page?

Convert string to lowercase AND then convert it to its original form in PHP, is it possible?

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

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

Custom post type single page not working

PHP: How to solve ob_start() in combination imagepng() issue?

Respond with status code 401 on authentication failure using Laravel and Passport?

php file upload scanning using clamav, permissions on /tmp/

How to make Canonicals with PHP

About Contact Privacy policy Terms and conditions