Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Place a PMPro member in another level when they cancel.
Plugin Name: Eighty/20 Results: Assign free level when cancelling
Plugin URI:
Description: Custom code to configure a default member level for a user who cancels
Version: 1.0
Requires at least: 4.5
Tested up to: 4.9.8
Author: Eighty / 20 Results by Wicked Strong Chicks, LLC <>
Author URI:
License URI:
License: GPLv2 or later
* Set the membership level ID your member should be assigned when they cancel
if (! defined('PMPRO_DOWNGRADE_TARGET' ) ) {
define( 'PMPRO_DOWNGRADE_TARGET', 1 ); // TODO: Change to the correct membership level ID
* Change membership level when the user's membership is cancelled/expired
* @param int $level_id
* @param int $user_id
function pmpro_after_change_membership_level_default_level($level_id, $user_id) {
// If we see this global set, then another gist is planning to give the user their level back
global $pmpro_next_payment_timestamp;
if ( ! empty( $pmpro_next_payment_timestamp ) ) {
if ( 0 == $level_id ) {
// Actually cancelling, give them PMPRO_DOWNGRADE_TARGET membership level instead
pmpro_changeMembershipLevel( PMPRO_DOWNGRADE_TARGET, $user_id);
add_action("pmpro_after_change_membership_level", "pmpro_after_change_membership_level_default_level", 999, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.