Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active February 19, 2019 23:25
Show Gist options
  • Save andrewlimaza/17251ea8091acdb322f6059dfda77df3 to your computer and use it in GitHub Desktop.
Save andrewlimaza/17251ea8091acdb322f6059dfda77df3 to your computer and use it in GitHub Desktop.
Redirect to a specific URL when a user uses email confirmation for PMPro for a certain level.
<?php
/**
* Redirect to URL depending on which level a user is validating for.
* Checks to see if a user currently has a level which will return true if logged in, if user is not logged in redirect them to login.
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmproec_after_validate_user() {
if( pmpro_hasMembershipLevel( 1 ) ) {
wp_redirect("/level-1-url/");
}elseif( pmpro_hasMembershipLevel( 2 ) ){
wp_redirect("/level-2-url");
}elseif( ! is_user_logged_in() ){
wp_redirect(wp_login_url("/membership-account/"));
}
exit;
}
add_filter('pmproec_after_validate_user', 'my_pmproec_after_validate_user');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment