I want to configure that link and I can’t, it doesn’t return me to the payment page.
I have this code to redirect users based on their membership.
/* ***** Redirecciones de LOGIN - Sample code to update login redirects for member */
function custom_login_redirect( $redirect_to, $request, $user ) {
if (pmpro_hasMembershipLevel(1, $user->ID)) {
return "/portal/";
}
elseif (pmpro_hasMembershipLevel(5, $user->ID)) {
return home_url( '/portal-1/' );
}
elseif (pmpro_hasMembershipLevel(6, $user->ID)) {
return home_url( '/portal-2/' );
}
elseif ( is_array( $user->roles ) && in_array( 'customer', $user->roles ) ) {
return home_url( '/escritorio/' );
}
return home_url();
}
add_filter( 'login_redirect', 'custom_login_redirect', 10, 3 );
and I am using this code so that when I log in from the “Already have an account? Sign in here” link on the checkout page, it return me to the checkout page and not working ??
function pmpro_checkout_login_redirect( $redirect_to, $request = NULL, $user = NULL ) {
global $wpdb;
$is_logged_in = ! empty( $user ) && ! empty( $user->ID );
if ( $is_logged_in && empty( $redirect_to ) ) {
// Can't use the pmpro_hasMembershipLevel function because it won't be defined yet.
$is_member = $wpdb->get_var( "SELECT membership_id FROM $wpdb->pmpro_memberships_users WHERE status = 'active' AND user_id = '" . esc_sql( $user->ID ) . "' LIMIT 1" );
if ( $is_member ) {
$redirect_to = pmpro_url( 'account' );
} else {
$redirect_to = pmpro_url( 'levels' );
}
}
return $redirect_to;
}
add_filter( 'pmpro_checkout_login_redirect','pmpro_checkout_login_redirect', 10, 3 );