Skip to content

Instantly share code, notes, and snippets.

@eighty20results
Created February 16, 2016 17:34
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/e38a062aa08dbf9e2880 to your computer and use it in GitHub Desktop.
Save eighty20results/e38a062aa08dbf9e2880 to your computer and use it in GitHub Desktop.
Custom fields for Register Helper
<?php
/*
Plugin Name: Additional Checkout Fields (PMPro Register Helper)
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Additional Checkout page & profile fields for the Paid Memberships Pro Register Helper add-on
Version: .1
Author: Thomas Sjolshagen @ Stranger Studios <thomas@eighty20results.com>
Author URI: http://www.strangerstudios.com
*/
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(
"home_group", // Input name, will also be used as the key to access as user meta
"select", // The type of field to use
array(
"label" => "Home Group", // Label to use for the field when displaying it
"class" => "pmpro_rh_homegroup", // 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" => true, // Make this field required (true | false)
'options' => array( // Options for the drop-down (select) field.
'alexandria' => "Alexandria",
'arlington' => "Arlington",
'virtual_daytime' => "Virtual (daytime)",
'washington_dc' => "
DC",
'tysons' => "Tyson's",
'leesburg' => "Leesburg",
'manassass' => "Manassass",
'woodbridge' => "Woodbridge",
'virtual_evening' => "Virtual (evening)",
)
)
);
$fields[] = new PMProRH_Field(
"company", // Input name, will also be used as the key to access as user meta
"text", // The type of field to use
array(
"label" => "Company", // Label to use for the field when displaying it
"size" => 40, // Size of the Input field
"class" => "pmpro_rh_company", // 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" => true // Make this field required (true | false)
)
);
$fields[] = new PMProRH_Field(
"address", // Input name, will also be used as the key to access as user meta
"text", // The type of field to use
array(
"label" => "Address", // Label to use for the field when displaying it
"size" => 40, // Size of the Input field
"class" => "pmpro_rh_address", // 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(
"website", // Input name, will also be used as the key to access as user meta
"text", // The type of field to use
array(
"label" => "Website", // Label to use for the field when displaying it
"size" => 40, // Size of the Input field
"class" => "pmpro_rh_website", // Custom CSS class to add (your choice)
"profile" => "only", // 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(
"phone", // Input name, will also be used as the key to access as user meta
"text", // The type of field to use
array(
"label" => "Phone", // Label to use for the field when displaying it
"size" => 40, // Size of the Input field
"class" => "pmpro_rh_phone", // 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" => 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