Last active
May 14, 2019 18:48
-
-
Save messica/444b989c6da49776c6437f0d58f147e5 to your computer and use it in GitHub Desktop.
Redirect on login if user has any failed payments. (Requires Paid Memberships Pro Failed Payment Limit Add On)
This file contains 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 on login if user has any failed payments. (Requires Paid Memberships Pro Failed Payment Limit Add On) | |
*/ | |
function my_pmpro_login_redirect_url( $url, $request, $user ) { | |
// Set failed payment redirect URL here. | |
$failed_payment_redirect_url = site_url( 'payment-failed' ); | |
if ( empty( $user->ID ) ) { | |
return; | |
} | |
$failed_payments = get_user_meta( $user->ID, 'pmpro_failed_payment_count', true ); | |
if ( $failed_payments ) { | |
return $failed_payment_redirect_url; | |
} | |
return $url; | |
} | |
add_filter( 'pmpro_login_redirect_url', 'my_pmpro_login_redirect_url', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment