Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active June 11, 2020 20:15
Show Gist options
  • Save andrewlimaza/bb1150acaf01ecd4f7b351488665cec4 to your computer and use it in GitHub Desktop.
Save andrewlimaza/bb1150acaf01ecd4f7b351488665cec4 to your computer and use it in GitHub Desktop.
redirect members away from a specific page for PMPro.
<?php
/**
* This will redirect members from Page A to Page B. Non-members will be able to access Page A.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_template_redirect_members() {
if ( is_page('join') && pmpro_hasMembershipLevel() ) {
wp_redirect(home_url( '/my-page-slug' ) );
exit;
}
}
add_action('template_redirect', 'my_template_redirect_members');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment