Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save JarrydLong/9c2346b13f6bd4588ee6bafcab967ad1 to your computer and use it in GitHub Desktop.
Save JarrydLong/9c2346b13f6bd4588ee6bafcab967ad1 to your computer and use it in GitHub Desktop.
Remove 'Renew' link and prevent checkout if user already has membership level
<?php
// Copy from below here.
add_action('pmpro_is_level_expiring_soon', '__return_false', 10, 2);
// Check if they have a specific level, and prevent them from signing up for a specific level
function my_pmpro_prevent_renewal( $continue ) {
global $pmpro_level;
if ( pmpro_hasMembershipLevel( array( 1, 7, 2 ) ) ) {
//They have level 1, 7 or 2, we don't want them to sign up for 11
if( ! empty( $_REQUEST['level'] ) && intval( $_REQUEST['level'] ) == 11 ) {
$continue = false;
pmpro_setMessage( 'You already have this level.', 'pmpro_error' );
}
}
return $continue;
}
add_filter( 'pmpro_registration_checks', 'my_pmpro_prevent_renewal' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment