• 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

run a query using EXECUTE BLOCK to prepair a column for an unique-Index

How can I get data from PHP to Android TextView?

Which is faster php date functions or carbon?

How can I make this nested location configuration use the correct path to call a php program?

php mysql + create a friend request system

Need to display only array value in JSON output

Extract house numbers from address string

I need to link Google Sheet with my Laravel

calling server using nusoap with complextype

How to create custom authentication in laravel 8?

Confirm Leave on External Links in Wordpress

Add a text next to stock quantity if it is less than 10 in Woocommerce single product

phpmyadmin : Depends: php-twig (>= 2.9) but 2.6.2-2 is to be installed. WHAT?

How to use functions that are declared in snippets in Evolution CMS (Modx) in an external PHP Script?

PHP - Check if string contains words longer than 4 characters, then include "+ *", and for those shorter than 4 characters include only "*"

About Contact Privacy policy Terms and conditions