• 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

Check If array is null or not in php

Coinpayments create_transaction "ERROR: Invalid command!"

Don't show recurring price for WooCommerce subscriptions worth 0$

Do I need to install `fxp/composer-asset-plugin` if I'm not doing front-end development

Woocommerce Checkout - Add conditional field required if one field is filled

PHP: Insert marker every 3 iterations

SQLSTATE[42S02]: Base table or view not found: 1146 Table 'posts.post' doesn't exist

Not able to access model in the controller mautic

getting error while enter Command => php artisan route:list

Lexik JWT authentication problem "Invalid credentials"

Add bold text and line break into Laravel Notification Email

PHP Fatal error: Class not found - PHPUnit

PHP contact form configuration [duplicate]

Sort a multidimensional array by integer inside of a string value which is two levels down

Currently Using CodeIgniter Framework i have an Error

About Contact Privacy policy Terms and conditions