Skip to content

Instantly share code, notes, and snippets.

@rumspeed
Created December 4, 2016 22:07
Show Gist options
  • Save rumspeed/8847616937e6e475e99c35c838be51d8 to your computer and use it in GitHub Desktop.
Save rumspeed/8847616937e6e475e99c35c838be51d8 to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Register Helper Fields
<?php
/*
Plugin Name: Paid Memberships Pro - Register Helper Fields
Description: Add custom fields to the Member Register page and User Profile
Version: 1.0.0
Author: Rumspeed
Author URI: http://www.rumspeed.com
*/
//we have to put everything in a function called on init, so we are sure Register Helper is loaded
function rum_pmprorh_custom_fields_init()
{
//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(
"phone", // input name, will also be used as meta key
"text", // type of field
array(
"size" =>20, // input size
"class" =>"phone", // custom class
"label" =>"Phone", // custom field label
"profile" =>true, // show in user profile
"required" =>true // make this field required
));
$fields[] = new PMProRH_Field(
"address", // input name, will also be used as meta key
"text", // type of field
array(
"size" =>50, // input size
"class" =>"address", // custom class
"label" =>"Address", // custom field label
"profile" =>true, // show in user profile
"required" =>true // make this field required
));
$fields[] = new PMProRH_Field(
"city", // input name, will also be used as meta key
"text", // type of field
array(
"size" =>25, // input size
"class" =>"city", // custom class
"label" =>"City", // custom field label
"profile" =>true, // show in user profile
"required" =>true // make this field required
));
$fields[] = new PMProRH_Field(
"state", // input name, will also be used as meta key
"text", // type of field
array(
"size" =>2, // input size
"class" =>"state", // custom class
"label" =>"State", // custom field label
"profile" =>true, // show in user profile
"required" =>false // make this field required
));
$fields[] = new PMProRH_Field(
"zipcode", // input name, will also be used as meta key
"text", // type of field
array(
"size" =>5, // input size
"class" =>"zipcode", // custom class
"label" =>"Zip Code", // custom field label
"profile" =>true, // show in user profile
"required" =>true // make this field required
));
$fields[] = new PMProRH_Field(
"business_card", // input name, will also be used as meta key
"file", // type of field
array(
"accept" =>"image/*", // approved mime types
"levels" =>3, // membership levels
"size" =>5, // input size
// "addmember" =>true, // display field in Add Member admin area
"class" =>"business-card", // custom class
"label" =>"Business Card", // custom field label
"profile" =>"only_admin", // show in user profile?
// "profile" =>true, // show in user profile
"required" =>false // make this field required
));
//add the fields into a new checkout_boxes are of the checkout page
foreach($fields as $field)
pmprorh_add_registration_field(
"after_email", // 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", "rum_pmprorh_custom_fields_init");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment