Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Last active April 21, 2026 15:57
Show Gist options
  • Select an option

  • Save andrewlimaza/5ac1ad41189d799e0ba4baab9a0d9e23 to your computer and use it in GitHub Desktop.

Select an option

Save andrewlimaza/5ac1ad41189d799e0ba4baab9a0d9e23 to your computer and use it in GitHub Desktop.
Allow query parameter &gateway=xxxx for multiple gateway options at checkout PMPro.
<?php
/**
* Allows you to hotswap gateway logic at checkout via query parameter.
* Helpful if the gateway doesn't have native gateway swapping capabilities.
* Add &gateway=paypal (for example) to your checkout URL to load the new PayPal payment gateway.
*
* Add this code to your site by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
add_filter( 'pmpro_valid_gateways', function( $gateways ) {
$gateways[] = 'paypal'; //Change paypal to any other gateway you have installed/configured.
return $gateways;
} );
// Add a small "Click here to checkout with PayPal" example link to reload the checkout and use PayPal.
add_action( 'pmpro_checkout_after_level_cost', function( $level ) {
if ( ! isset( $_REQUEST['gateway'] ) ) {
echo '<p><a href="' . esc_url( add_query_arg( 'gateway', 'paypal' ) ) . '">Click here to checkout with PayPal</a></p>';
}
} );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment