I was wondering if someone could help me out.
I have a plugin called Paid Memberships Pro.
On the signup form there are some fields i want to make required.
I have gone through the code and found the place where it sets which fields are required and not required, as below:
//require fields
$pmpro_required_billing_fields = array(
"bfirstname" => $bfirstname,
"blastname" => $blastname,
"baddress1" => $baddress1,
"bcity" => $bcity,
"bstate" => $bstate,
"bzipcode" => $bzipcode,
"bphone" => $bphone,
"bcountry" => $bcountry,
"bemail" => $bemail,
"CardType" => $CardType,
"AccountNumber" => $AccountNumber,
"ExpirationMonth" => $ExpirationMonth,
"ExpirationYear" => $ExpirationYear,
"CVV" => $CVV
);
$pmpro_required_billing_fields = apply_filters("pmpro_required_billing_fields", $pmpro_required_billing_fields);
$pmpro_required_user_fields = array(
"username" => $username,
"password" => $password,
"password2" => $password2,
"bemail" => $bemail,
"bconfirmemail" => $bconfirmemail
);
$pmpro_required_user_fields = apply_filters("pmpro_required_user_fields", $pmpro_required_user_fields);
This is found in one of the plugins core files plugins/paid-memberships-pro/preheaders/checkout.php
I want to be able to override this, but i dont want to edit the core files, is there a way i can edit this via my themes functions.php file?
For instance, add the bfirstname and blastname to the $pmpro_required_user_fields?
Any help would be greatly appreciated, ive been searching how to do this but i cant really understand if its possible.
Thanks all :)
I found a bit of code that worked perfectly
//make sure address fields are required
function my_pmpro_required_user_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_user_fields", "my_pmpro_required_user_fields");
/*
* Save billing fields when using PayPal
*/
function my_pmpro_paypalexpress_session_vars() {
$_SESSION['bfirstname'] = $_REQUEST['bfirstname'];
$_SESSION['blastname'] = $_REQUEST['blastname'];
$_SESSION['baddress1'] = $_REQUEST['baddress1'];
$_SESSION['baddress2'] = $_REQUEST['baddress2'];
$_SESSION['bcity'] = $_REQUEST['bcity'];
$_SESSION['bstate'] = $_REQUEST['bstate'];
$_SESSION['bzipcode'] = $_REQUEST['bzipcode'];
$_SESSION['bphone'] = $_REQUEST['bphone'];
$_SESSION['bemail'] = $_REQUEST['bemail'];
$_SESSION['bcountry'] = $_REQUEST['bcountry'];
}
add_action('pmpro_paypalexpress_session_vars', 'my_pmpro_paypalexpress_session_vars');
//load vars back into $_REQUEST
function my_init() {
if(!empty($_REQUEST['review']) && !empty($_REQUEST['token'])) {
$_REQUEST['bfirstname'] = $_SESSION['bfirstname'];
$_REQUEST['blastname'] = $_SESSION['blastname'];
$_REQUEST['baddress1'] = $_SESSION['baddress1'];
$_REQUEST['baddress2'] = $_SESSION['baddress2'];
$_REQUEST['bcity'] = $_SESSION['bcity'];
$_REQUEST['bstate'] = $_SESSION['bstate'];
$_REQUEST['bzipcode'] = $_SESSION['bzipcode'];
$_REQUEST['bphone'] = $_SESSION['bphone'];
$_REQUEST['bemail'] = $_SESSION['bemail'];
$_REQUEST['bcountry'] = $_SESSION['bcountry'];
}
}
add_action('init', 'my_init');