Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kimcoleman/33a2e2dd6dfe908d5a8f5714ad150bd2 to your computer and use it in GitHub Desktop.
Save kimcoleman/33a2e2dd6dfe908d5a8f5714ad150bd2 to your computer and use it in GitHub Desktop.
Redirect non-members to the Membership Levels page in PMPro if they do not have a membership level.
<?php
/**
* Redirect non-members to the Membership Levels page if they do not have a membership level.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*
*/
function redirect_non_members_to_levels_page( $url ) {
$url = pmpro_url( 'levels' );
return $url;
}
add_filter( 'pmpro_account_preheader_redirect', 'redirect_non_members_to_levels_page' );
@laurenhagan0306
Copy link

This recipe is included in the blog post on "Redirect Non-Members Away From the Membership Account Page" at Paid Memberships Pro here: https://www.paidmembershipspro.com/redirect-non-members-from-membership-account/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment