Skip to content

Instantly share code, notes, and snippets.

@rvdsteege
Last active July 22, 2021 12:35
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 rvdsteege/092251e73b02f8709ffa8b90c9ed8fb9 to your computer and use it in GitHub Desktop.
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.
<?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