Created
June 1, 2021 20:51
-
-
Save dparker1005/481e8d1555b126d9f90afd13f3e08f6f to your computer and use it in GitHub Desktop.
Prevent users from cancelling their membership or checking out for a new one.
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... | |
/** | |
* Prevent users from cancelling their membership or checking out for a new one. | |
*/ | |
function my_pmpro_redirect_from_checkout_and_cancel() { | |
global $pmpro_pages; | |
$user_level = pmpro_getMembershipLevelForUser(); | |
if ( empty( $user_level ) || ! function_exists( 'pmprosm_isSponsoredLevel' ) ) { | |
return; | |
} | |
if ( ( ! empty($pmpro_pages['cancel']) && is_page($pmpro_pages['cancel'] ) ) || | |
( ! empty($pmpro_pages['levels']) && is_page($pmpro_pages['levels'] ) ) || | |
( ! empty($pmpro_pages['checkout']) && is_page($pmpro_pages['checkout'] ) ) ) { | |
if ( ! empty( $pmpro_pages['account'] ) ) { | |
wp_redirect(pmpro_url('account')); | |
exit; | |
} else { | |
wp_redirect( home_url() ); | |
} | |
} | |
} | |
add_action('template_redirect', 'my_pmpro_redirect_from_checkout_and_cancel', 5); | |
/** | |
* Hide action links on profile page. | |
*/ | |
function my_pmpro_hide_action_links() { | |
global $pmpro_pages; | |
$user_level = pmpro_getMembershipLevelForUser(); | |
if ( empty( $user_level ) ) { | |
return; | |
} | |
if ( is_page( $pmpro_pages['account'] ) ) { | |
?> | |
<style> | |
.pmpro_actionlinks { display:none; } | |
</style> | |
<?php | |
} | |
} | |
add_action( 'wp_footer', 'my_pmpro_hide_action_links' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment