Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidmutero/1c52c19fbb23e76d3e93ee4517a588d2 to your computer and use it in GitHub Desktop.
Save davidmutero/1c52c19fbb23e76d3e93ee4517a588d2 to your computer and use it in GitHub Desktop.
Reorder PMPro checkout fields to Email and Password. #pmpro #paid-memberships-pro #checkout
<?php
/**
* This recipe moves the checkout fields to appear in the order of
* 1. Email
* 2. Password.
*
* Email fields will be moved (always) to before password fields
* on the checkout page.
*
* You can add this recipe to your site by creating a custom plugin
* or using the Code Snippets plugin available for free in the WordPress repository.
* Read this companion article for step-by-step directions on either method.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmpro_reorder_fields_names_email_password() {
global $pmpro_pages;
if ( is_page( $pmpro_pages['checkout'] ) ) {
?>
<script>
jQuery(document).ready(function(){
var cols = jQuery('.pmpro_cols-2');
if (cols.length >= 2) {
cols.eq(1).insertBefore(cols.eq(0));
}
});
</script>
<?php
}
}
add_action( 'wp_footer', 'my_pmpro_reorder_fields_names_email_password' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment