• 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

Laravel implode array items to new lines

Create a zip file and download it

How to properly set "0000-00-00 00:00:00" as a DateTime in PHP

Cant seem to get the Pagination to work on my WooCommerce REST API application?

Why getting "Build step 'Execute shell' marked build as failure" error while creating a backup tar for files

Star and Half Star Rating in Laravel

User pool client {id}does not exist

How to validate tin and cst using PHP?

PHP Slim Framework request using withAttribute error

Symfony - "framework.test" config is not set to true

How to edit Records using CodeIgniter

args[max_input] woocommerce if statement confused

SlimExceptionHttpNotFoundException

How can I solve "laravel/horizon v1.1.0 requires ext-pcntl * -> the requested PHP extension pcntl is missing from your system"?

How to break out of a foreach once a condition is met?

About Contact Privacy policy Terms and conditions