Skip to content

Instantly share code, notes, and snippets.

@eighty20results
Created February 16, 2016 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eighty20results/3b0ef5c6cfc036f66bf1 to your computer and use it in GitHub Desktop.
Save eighty20results/3b0ef5c6cfc036f66bf1 to your computer and use it in GitHub Desktop.
Register Helper fields that also use the default WordPress meta field names for "First name" and "Last name".
<?php
function my_add_pmpro_RH_fields()
{
//require PMPro and PMPro Register Helper
if (!defined('PMPRO_VERSION') || !defined('PMPRORH_VERSION'))
return;
$fields = array();
$fields[] = new PMProRH_Field(
"first_name", // Input name, will also be used as the key to access as user meta
"text", // The type of field to use
array(
"label" => "First name", // Label to use for the field when displaying it
"size" => 40, // Size of the Input field
"class" => "pmpro_rh_names", // Include in the user's profile (true | false | 'only' | 'only_admin')
"profile" => false, // Include in the user's profile
"memberslistcsv" => false, // Let field be included in "Member List" CSV export (true | false)
"addmember" => false, // Used if the "Add Member Admin" add-on is present (true | false)
"required" => false // Make this field required (true | false)
)
);
$fields[] = new PMProRH_Field(
"last_name", // Input name, will also be used as the key to access as user meta
"text", // The type of field to use
array(
"label" => "Last name", // Label to use for the field when displaying it
"size" => 40, // Size of the Input field
"class" => "pmpro_rh_names", // Custom CSS class to add (your choice)
"profile" => false, // Include in the user's profile (true | false | 'only' | 'only_admin')
"memberslistcsv" => false, // Let field be included in "Member List" CSV export (true | false)
"addmember" => false, // Used if the "Add Member Admin" add-on is present (true | false)
"required" => false // Make this field required (true | false)
)
);
$fields[] = new PMProRH_Field(
"organization_name", // Input name, will also be used as the key to access as user meta
"text", // The type of field to use
array(
"label" => "Organization name", // Label to use for the field when displaying it
"size" => 40, // Size of the Input field
"class" => "pmpro_rh_names", // Custom CSS class to add (your choice)
"profile" => true, // Include in the user's profile (true | false | 'only' | 'only_admin')
"memberslistcsv" => true, // Let field be included in "Member List" CSV export (true | false)
"addmember" => true, // Used if the "Add Member Admin" add-on is present (true | false)
"required" => true // Make this field required (true | false)
)
);
//Add the fields into a new checkout_boxes are of the checkout page
foreach($fields as $field)
{
// Add the field(s) to the checkout page.
pmprorh_add_registration_field(
"checkout_boxes", // location on checkout page
$field // PMProRH_Field object
);
}
}
add_action("init", "my_add_pmpro_RH_fields");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment