Skip to content

Instantly share code, notes, and snippets.

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 andrewlimaza/e901fdac84de21e61f72dc3c8fbc1382 to your computer and use it in GitHub Desktop.
Save andrewlimaza/e901fdac84de21e61f72dc3c8fbc1382 to your computer and use it in GitHub Desktop.
Force billing fields for Paid Memberships Pro for specific levels.
<?php
/**
* Force billing fields for specific levels (line 9) for Authorize.net and Paid Memberships Pro.
* Add this code to your site by following these steps: https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function al_force_billing_fields_pmpro_authorize_net( $fields ) {
$levels_array = array( 1,3 ); // change this to levels that require billing fields.
if ( isset( $_REQUEST['level'] ) && in_array( $_REQUEST['level'], $levels_array ) ) {
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", "al_force_billing_fields_pmpro_authorize_net", 30);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment