• 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

MySQL order by field in Eloquent

Required field only if another field has a value, must be empty otherwise

how to see if database exists with PDO [duplicate]

MySQL upgrade causing unexpected results on simple WHERE clauses

Mobile browsers are adding .html to filename on download

Laravel lang slug in url

Woocommerce product attributes with hierarchy like categories

Redirect to previous page with php

GRPC installed successfully on ubuntu but php is looking for it in another folder

wordpress : How to specify the cause "This site can’t be reached"

Update Total in checkout of Woocommerce with Ajax Request

browsersync doesn't work with XAMPP

What will the best solution for this multiple optional filter?

PHP - Store information with NO database

How to solve cURL error 60: SSL certificate in Laravel 5 while Facebook authentication

About Contact Privacy policy Terms and conditions