• 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

PHP: How to quickly split a key=value file into associative array

Maatwebsite Excel 3.1 : how do I skip duplicate data when imported?

WAMP/Wordpress - cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received

Get sum of arrays inside array

Mysqli multi query error

Correctly determine if date string is a valid date in that format

how to create html table in php

Display specific shipping method if woocommerce product has specific acf field value

Combining a describing and one array with data

PHP mail function is sending blank message body

Laravel passport auth token not working after moving to different server

How to display table header in every page using FPDF library?

loop through an anchor id

How to pass data to all views in Laravel 5?

How to remove index.php and index from the URL using htaccess | PHP

About Contact Privacy policy Terms and conditions