Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidmutero/39eff55b0951286b7462a53ede953bfa to your computer and use it in GitHub Desktop.
Save davidmutero/39eff55b0951286b7462a53ede953bfa to your computer and use it in GitHub Desktop.
Move a User Field Group Below the Billing Address on PMPro Checkout
<?php
/**
* Move a specific user field group (e.g. Company Info) below the Billing Address on PMPro Checkout.
*
* This uses JavaScript to reposition any fieldset by targeting its ID.
* Update the `$fieldset_id` value to match the fieldset you want to move.
*
* 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.
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function move_user_fieldset_after_billing_address() {
if ( is_page( pmpro_getOption( 'checkout' ) ) ) {
$fieldset_id = 'pmpro_form_fieldset-user-fieldset'; // Update to your fieldset ID
?>
<script>
document.addEventListener('DOMContentLoaded', function () {
const userFieldset = document.querySelector('#<?php echo esc_js( $fieldset_id ); ?>');
const billingFields = document.querySelector('#pmpro_billing_address_fields');
if (userFieldset && billingFields) {
billingFields.parentNode.insertBefore(userFieldset, billingFields.nextSibling);
}
});
</script>
<?php
}
}
add_action( 'wp_footer', 'move_user_fieldset_after_billing_address' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment