Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active July 2, 2019 22:33
Show Gist options
  • Save andrewlimaza/414e4cf9712d25a57c73919bf1f72825 to your computer and use it in GitHub Desktop.
Save andrewlimaza/414e4cf9712d25a57c73919bf1f72825 to your computer and use it in GitHub Desktop.
Stop users from changing membership level on checkout on WooCommerce
<?php
/**
* Stop existing members from changing levels when purchasing a product on WooCommerce.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function woo_dont_apply_level_for_existing_members() {
if ( pmpro_hasMembershipLevel( '1' ) ) {
remove_action( 'woocommerce_order_status_completed', 'pmprowoo_add_membership_from_order' );
}
}
add_action( 'woocommerce_order_status_completed', 'woo_dont_apply_level_for_existing_members', 5 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment