Skip to content

Instantly share code, notes, and snippets.

@greathmaster
Created December 14, 2015 17:03
Show Gist options
  • Select an option

  • Save greathmaster/bf3d7a89a10bef688a42 to your computer and use it in GitHub Desktop.

Select an option

Save greathmaster/bf3d7a89a10bef688a42 to your computer and use it in GitHub Desktop.
Add Custom Fields from Register Helper to GetResponse
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists("pmprorh_add_registration_field"))
{
return false;
}
//define the fields
$fields = array();
$fields[] = new PMProRH_Field(
"company", // input name, will also be used as meta key
"text", // type of field
array(
"size"=>40, // input size
"label"=>"Company",
"profile"=>true, // show in user profile
));
$fields[] = new PMProRH_Field(
"city", // input name, will also be used as meta key
"text", // type of field
array(
"size"=>40, // input size
"label"=>"City",
"profile"=>true, // show in user profile
"required"=>true // make this field required
));
$fields[] = new PMProRH_Field(
"state", // input name, will also be used as meta key
"text", // type of field
array(
"size"=>40, // input size
"label"=>"State",
"profile"=>true, // show in user profile
"required"=>true // make this field required
));
$fields[] = new PMProRH_Field(
"postal_code", // input name, will also be used as meta key
"text", // type of field
array(
"size"=>40, // input size
"label"=>"Postal Code",
"profile"=>true, // show in user profile
"required"=>true // make this field required
));
$fields[] = new PMProRH_Field(
"category", // input name, will also be used as meta key
"text", // type of field
array(
"size"=>40, // input size
"label"=>"Category",
"profile"=>true, // show in user profile
"required"=>true // make this field required
));
//add the fields into a new checkout_boxes are of the checkout page
foreach($fields as $field)
pmprorh_add_registration_field(
"checkout_boxes", // location on checkout page
$field // PMProRH_Field object
);
//that's it. see the PMPro Register Helper readme for more information and examples.
}
add_action("init", "my_pmprorh_init");
function my_pmpro_getresponse_custom_fields() {
$fields = array(
'company' => $_REQUEST['company'],
'city' => $_REQUEST['city'],
'state' => $_REQUEST['state'],
'postal_code' => $_REQUEST['postal_code'],
'category' => $_REQUEST['category'],
);
return $fields;
}
add_filter('pmpro_getresponse_custom_fields', 'my_pmpro_getresponse_custom_fields');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment