Skip to content

Instantly share code, notes, and snippets.

@insaurabh
Last active May 8, 2018 06:09
Show Gist options
  • Save insaurabh/b78c2f25de094b86c714b5e426c6be2f to your computer and use it in GitHub Desktop.
Save insaurabh/b78c2f25de094b86c714b5e426c6be2f to your computer and use it in GitHub Desktop.
Custom additional values using pmpro-register-helper
function my_pmprorh_init()
{
$last_university = get_option('last_university');
$last_university = explode(',', $last_university);
$highest_level_of_education = get_option('highest_level_of_education');
$highest_level_of_education = explode(',', $highest_level_of_education);
// print_r($last_university);
if (!function_exists('pmprorh_add_registration_field'))
{
return false;
}
$fields = array();
$fields[] = new PMProRH_Field(
"select_last_university_opt", // input name, will also be used as meta key
"select", // type of field
array(
"label" => "Last University",
'options' => $last_university,
'profile' => true, //show in user's profile
'memberslistcsv' => true
));
$fields[] = new PMProRH_Field(
"select_highestLevel_edu_opt",
"select",
array(
"label"=>"Highest level of Education",
'options'=> $highest_level_of_education,
'profile' => true,
'memberslistcsv' => true
));
//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_pmprorh_init()
{
$last_university = get_option('last_university');
$last_university = explode(',', $last_university);
$highest_level_of_education = get_option('highest_level_of_education');
$highest_level_of_education = explode(',', $highest_level_of_education);
if (!function_exists('pmprorh_add_registration_field'))
{
return false;
}
$fields = array();
$fields[] = new PMProRH_Field(
"select_last_university_opt", // input name, will also be used as meta key
"select", // type of field
array(
"label"=>"Last University",
'options'=> $last_university,
"profile"=>true //show in user's profile
));
$fields[] = new PMProRH_Field(
"select_highestLevel_edu_opt", // input name, will also be used as meta key
"select", // type of field
array(
"label"=>"Highest level of Education",
'options'=> $highest_level_of_education,
"profile"=>true //show in user's profile
));
//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");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment