• 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

PHP and WebView - Cookie doesn't are the same

php - add comma thousands separator but remove trailing zeros

Limit of log line written to Apache Errorlog from mod php error_log

How to find the date a user created their Google account

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

how to check version of codeigniter framework?

Docker image build with PHP zip extension shows "bundled libzip is deprecated" warning

How to run or debug php on Visual Studio Code (VSCode)

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

Laravel Command Schedule Not Working Properly

How to change HTML structure inside WP <head>

XSS attack still works despite htmlspecialchars() doing its work

Substitute integers and dots with regex [duplicate]

I'm trying to write a clean url for my website using the $_SERVER['REQUEST_URI'] in php

Pagekite error: FAIL: localhost:8080 is down

About Contact Privacy policy Terms and conditions