Skip to content

Instantly share code, notes, and snippets.

@kimcoleman
Last active November 25, 2020 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kimcoleman/8a04009bc686e7efd0c0bb9f913b73f1 to your computer and use it in GitHub Desktop.
Save kimcoleman/8a04009bc686e7efd0c0bb9f913b73f1 to your computer and use it in GitHub Desktop.
Make sure address fields are required
<?php
/**
* Make sure Billing Address fields are required.
*
* 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_required_billing_fields( $fields ) {
global $bfirstname, $blastname, $baddress1, $bcity, $bstate, $bzipcode, $bcountry, $bphone, $bemail;
$fields[ 'bfirstname' ] = $bfirstname;
$fields[ 'blastname' ] = $blastname;
$fields[ 'baddress1' ] = $baddress1;
$fields[ 'bcity' ] = $bcity;
$fields[ 'bstate' ] = $bstate;
$fields[ 'bzipcode' ] = $bzipcode;
$fields[ 'bphone' ] = $bphone;
$fields[ 'bemail' ] = $bemail;
$fields[ 'bcountry' ] = $bcountry;
return $fields;
}
add_action( 'pmpro_required_billing_fields', 'my_pmpro_required_billing_fields', 30 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment