Forked from travislima/my_pmpro_login_redirect_url.php
Created
January 15, 2020 11:41
-
-
Save MaryOJob/34fde6dceedea954f4d4f223b7f88717 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 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 on login if user has any failed payments. (Requires Paid Memberships Pro Failed Payment Limit Add On) | |
* Adjust the code on the line the line "site_url( ' payment-failed')" to redirect to page of your prefereance. | |
* Add this code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
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 ) { | |
$url = site_url( 'payment-failed' ); | |
} | |
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