Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Redirect on login if user has any failed payments. (Requires Paid Memberships Pro Failed Payment Limit Add On)
<?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
You can’t perform that action at this time.