• 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

get data-value with variable value

Change user role if checkout custom checkbox is checked in WooCommerce

No definition found for function in vendor vscode

301 Redirect to remove query string on homepage only

HTML + PHP + PHPMAILER

Codeigniter, Severity: error --> Exception: Too few arguments to function, admin dashboard shows HTTP error 500

How to put php code inside opening and closing shortcodes

merging two arrays with specified index

Wordpress 'post_type_link' hides permalink

Performance of foreach, array_map with lambda and array_map with static function

Xdebug can't connect back to Docker host

php - add comma thousands separator but remove trailing zeros

WAMP/Wordpress - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

Check if my GET request has Header: Token

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

About Contact Privacy policy Terms and conditions