• 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

How to find phpcs current default standard

Laravel/docker-compose/redis - Class 'Redis' not found

php curl requesting twice

Limit login attempts in Laravel 5.7

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

PHP random string generator

Custom API and cunsuming in php?

HTML and PHP in one file

How to modify CSS in a specific page of the WP admin dashboard (backend)

PHPSpreadsheet - How Do I Use Auto Migration Tool

Using Associative arrays

Check if my GET request has Header: Token

Change user role if checkout custom checkbox is checked in WooCommerce

How to separate letters and digits from a string in php

No definition found for function in vendor vscode

About Contact Privacy policy Terms and conditions