Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Adding A Custom Field (Select & Text) to Register Helper
<?php
/**
* Register Helper example for a select and text field.
* Please add the below code to your custom plugin or Code Snippets Plugin by following this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function my_pmprorh_init() {
//don't break if Register Helper is not loaded
if(!function_exists( "pmprorh_add_registration_field" )) {
return false;
}
$fields = array();
$fields[] = new PMProRH_Field(
'school_or_organization_1', // input name, will also be used as meta key
'text', // type of field
array(
'label' => "School or Organization",
'required' => true, // make this field required
'profile' => true, // show in user profile
));
$fields[] = new PMProRH_Field(
'school_or_organization_type', // input name, will also be used as meta key
'select', // type of field
array(
'label' => "School or Organization Type",
'required' => true, // make this field required
'profile' => true, // show in user profile
'options' => array( // <option> elements for select field
"" => "Please Select", // blank option - cannot be selected if this field is required
"school or educator" =>"School or Educator",
"ag host" => "AG Host",
"business" => "Business",
)
));
//add the fields into a new checkout_boxes are of the checkout page
foreach($fields as $field)
pmprorh_add_registration_field(
'after_email', // 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");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.