Skip to content

Instantly share code, notes, and snippets.

@kimcoleman
Created July 25, 2020 13:31
Show Gist options
  • Save kimcoleman/c1bece290e7df29ef11fbfc170f414bc to your computer and use it in GitHub Desktop.
Save kimcoleman/c1bece290e7df29ef11fbfc170f414bc to your computer and use it in GitHub Desktop.
Custom fields at membership checkout for just state.
<?php
/**
* Custom fields at membership checkout for just state.
*
*/
function just_states_pmprorh_init() {
global $pmpro_states;
//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(
'pmp_state',
'select',
array(
'label'=>'State',
'profile'=>true,
'required' => true,
'options' => $pmpro_states,
));
//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", "just_states_pmprorh_init");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment