• 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 to reset Laravel AuthManager/guards in between API calls in tests?

Fatal error: Uncaught mysqli_sql_exception: Unknown database 'test' in ... (How do I fix that? Using PHP)

How to change the app environment at run time?

PHPSpreadsheet - How Do I Use Auto Migration Tool

Error converting docx to pdf using Unoconv

Minimum order amount except for specific shipping method in WooCommerce

PHP Imap , php 7.4.3 on mac osx catalina

How to create a individual template for page or post in custom plugin?

how to redirect the user back to desired URL after login page in PHP?

echo language construct is discouraged. (PHP)

Add customer email and phone in "Order" column to admin orders list on Woocommerce

How to solve Duplicate entry '0' for key 'PRIMARY' in Wordpress?

NGINX: connect() to unix:/var/run/php7.2-fpm.sock failed (2: No such file or directory)

Filter WooCommerce products with post__in and additional meta queries

Distribute array row data to make multiple new rows

About Contact Privacy policy Terms and conditions