Skip to content

Instantly share code, notes, and snippets.

View ArmandoValencia's full-sized avatar

Armando Valencia ArmandoValencia

View GitHub Profile
@ideadude
ideadude / my_pmprowoo_is_purchasable.php
Created July 1, 2020 22:39
Change the default PMPro WooCommerce bahavior and make membership products not purchasable if a user already has any other membership level.
<?php
/**
* Change the default PMPro WooCommerce bahavior
* and make membership products not purchasable
* if a user already has any other membership level.
*/
// First disable the core PMPro WC callaback and set up our own.
function my_pmprowoo_init() {
remove_filter( 'woocommerce_is_purchasable', 'pmprowoo_is_purchasable', 10, 2 );
add_filter( 'woocommerce_is_purchasable', 'my_pmprowoo_is_purchasable', 5, 2 );
@strangerstudios
strangerstudios / pmpro_cancelled_level.php
Last active May 12, 2021 22:05
Place a PMPro member in another level when they cancel.
/*
When users cancel (are changed to membership level 0) we give them another "cancelled" level. Can be used to downgrade someone to a free level when they cancel.
*/
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))
return;