Forked from kerijacoby/my_pmpro_prevent_renewal.php
Created
November 28, 2023 10:28
-
-
Save JarrydLong/9c2346b13f6bd4588ee6bafcab967ad1 to your computer and use it in GitHub Desktop.
Remove 'Renew' link and prevent checkout if user already has membership level
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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