Created
March 26, 2019 18:04
-
-
Save kimcoleman/e8fea3c3eee12f5fd8ba22fc467a030d to your computer and use it in GitHub Desktop.
Redirect members after login to 'dashboard' page slug or custom page as defined by Advanced Custom Fields.
This file contains hidden or 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 | |
/* | |
* Redirect members after login to 'dashboard' page slug or custom page as defined by ACF. | |
*/ | |
function coursecats_pmpro_login_redirect_url( $redirect_to, $request, $user ) { | |
// If logged in and a member, redirect them. | |
if ( ! empty( $user->ID ) && function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel( NULL, $user->ID ) ) { | |
$pmp_login_redirect_permalink = "dashboard"; | |
if ( function_exists( 'get_field' ) && get_field( 'pmp_login_redirect_permalink','options' ) ) { | |
$pmp_login_redirect_permalink = get_field( 'pmp_login_redirect_permalink','options' ); | |
} | |
$redirect_to = $pmp_login_redirect_permalink; | |
} | |
return $redirect_to; | |
} | |
add_filter( 'pmpro_login_redirect_url', 'coursecats_pmpro_login_redirect_url', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment