• 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 5.1 xmlHttpRequest AJAX POST TokenMismatchException

Unable to Edit config.inc.php

Adding multiple items to WooCommerce cart at once

Get number of working days between two dates in PHP [duplicate]

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

Creating command to backup MySql database in Laravel

Access relation of pivot table in Laravel

Manage independently the decimal number of the price of each product [duplicate]

Convert PHP array into HTML tag attributes separated by spaces

JQuery content editable div and text box on submit not sending POST

Symfony Mercure "Failed to send an update"

Only on Firefox "Loading failed for the <script> with source"

Laravel-fopen: failed to open stream: Permission denied

PHP file_get_contents function

Check if string contains a value in array [duplicate]

About Contact Privacy policy Terms and conditions