Skip to content

Instantly share code, notes, and snippets.

@MaximilianoRicoTabo
Created March 7, 2024 13:13
Show Gist options
  • Save MaximilianoRicoTabo/bf65e10ec21536d0a531d513bb0246e4 to your computer and use it in GitHub Desktop.
Save MaximilianoRicoTabo/bf65e10ec21536d0a531d513bb0246e4 to your computer and use it in GitHub Desktop.
Remove user fields at checkout page. Skip required fields check as well.
<?php
/**
*
* Custom recipe to hide user fields at checkout
*
* link: TBD
*
* 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/
*
*/
//hide the user fields if the level is number 6
function custom_pmpro_checkout_boxes_fields() {
//get the level
$level = pmpro_getLevelAtCheckout();
//if the level is 5 (Gift 1 Year USLA Membership), hide the user fields
if($level->id == 5) {
// remove pmpro_checkout_boxes_fields action
remove_action('pmpro_checkout_boxes', 'pmpro_checkout_boxes_fields');
return;
}
}
add_action( 'pmpro_checkout_boxes', 'custom_pmpro_checkout_boxes_fields', 9, 0 );
function custom_pmpro_remove_registration_user_fields_checks() {
$level = pmpro_getLevelAtCheckout();
//Gift 1 Year USLA Membership
if($level->id == 5) {
remove_filter( 'pmpro_registration_checks', 'pmpro_registration_checks_for_user_fields' );
}
}
add_action('pmpro_checkout_after_parameters_set', 'custom_pmpro_remove_registration_user_fields_checks', 10, 0);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment