Paid Memberships Pro: Send Members From the Levels Page to Their Account
Redirects members who already have a level away from the levels page to their membership account page, unless they came to change their level.
Opens WPIDE on
Code
if ( ! function_exists( 'pmpro_hasMembershipLevel' ) ) {
return;
}
add_action( 'template_redirect', function () {
global $pmpro_pages;
if ( empty( $pmpro_pages['levels'] ) || ! is_page( (int) $pmpro_pages['levels'] ) || isset( $_GET['change'] ) ) {
return;
}
if ( is_user_logged_in() && pmpro_hasMembershipLevel() ) {
wp_safe_redirect( pmpro_url( 'account' ) );
exit;
}
} );
Notes
Add ?change=1 to links where members should be able to pick a new level.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.