Skip to content

Instantly share code, notes, and snippets.

@eighty20results
Created February 16, 2016 15:54
Show Gist options
  • Save eighty20results/f111618c151fd9b71ee9 to your computer and use it in GitHub Desktop.
Save eighty20results/f111618c151fd9b71ee9 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
/*
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 <[email protected]>
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(
"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" => false, // 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