• 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

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

Log a user out of a website when they put their computer to sleep

php mysql + create a friend request system

Can't exclude directories from .htaccess mobile redirect?

PHP/HTML: Creating A SubMenu

Log file is not being written in Laravel 5.5

Cant seem to get the Pagination to work on my WooCommerce REST API application?

merge all files in directory to one text file

Fatal error: Uncaught Error: Call to undefined method mysqli_stmt::fetch_assoc() [duplicate]

Why rand() every time I refresh the page?

laravel sanctum Route [login] not defined

Correct way to use LIKE '%{$var}%' with prepared statements?

VichUploaderBundle error "Expected argument of type "File", "NULL" given" when submitting the form without selecting any file

How Can I Do LIMIT 1, 2 In WP_Query

MySQL upgrade causing unexpected results on simple WHERE clauses

About Contact Privacy policy Terms and conditions