• 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

Toggle between a textbox and a select using PHP

mysql_result is defined but mysql_free_result warns it expected a resource

AJAX call fails with SyntaxError: Unexpected end of JSON input

Passing PHP JSON to Javascript: echo json_encode vs echo json declaration

(PHPUnit) PHP Fatal error: Uncaught Error: Call to undefined function each()

What is my SQL missing?

Where do I need to place a hook for phpunit?

How to insert Google Adsense Code in PHP script?

Facebook PHP SDK - will not logout properly

Limit WooCommerce products in cart only from one custom taxonomy

how do i retrieve and display the alt text of an image in wordpress?

Sliders in Laravel

How to create laravel storage symbolic link for production or sub domain system?

PHP echo values of all sub keys [duplicate]

Substitute integers and dots with regex [duplicate]

About Contact Privacy policy Terms and conditions