• 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 can I remove the "Advanced" panel of all blocks in WordPress block editor?

How to connect to MSSQL Server with PHP from Ubuntu 18.04?

How to Install Composer Require doctrine/dbal

Warning file_get_contents () failed to open stream: HTTP request failed! HTTP/1.0 402 Payment Required

WooCommerce - unset "<product> removed notice…" on cart page

Need to display only array value in JSON output

I want to display default profile image if user do not have profile image

php code to send checkbox form results to email

php file upload scanning using clamav, permissions on /tmp/

Adding Multiple Custom Post Types in Wordpress

Multiple order by in WooCommerce

Display Brand Name Above Product Title in Woocommerce Cart, Checkout Page, Orders and Email Notification

add_action() function in wordpress not working [duplicate]

I cannot create a auto generated date time in mysql workbench

Multiply each value in array using array_map function

About Contact Privacy policy Terms and conditions