Last active
July 22, 2021 12:35
-
-
Save rvdsteege/092251e73b02f8709ffa8b90c9ed8fb9 to your computer and use it in GitHub Desktop.
MemberPress does not have anti double click on the `#payment-form` submit button, which can result in duplicate payments/subscriptions with the Pronamic Pay plugin. This can be fixed by adding this gist to the `functions.php` file of the WordPress theme.
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 | |
/** | |
* Prevent double click on MemberPress payment form (#payment-form). | |
* | |
* @return void | |
*/ | |
add_action( 'wp_footer', 'memberpress_prevent_duplicate_payment' ); | |
function memberpress_prevent_duplicate_payment() { | |
?> | |
<script type="text/javascript"> | |
(function($) { | |
$(document).ready( function() { | |
$('body').on( 'click', '#payment-form .mepr-submit', function( e ) { | |
e.preventDefault(); | |
this.disabled = true; | |
jQuery( this ).parents('form').submit(); | |
}); | |
}); | |
})( jQuery ); | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment