Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MaryOJob/34fde6dceedea954f4d4f223b7f88717 to your computer and use it in GitHub Desktop.
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)
<?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