Skip to content

Instantly share code, notes, and snippets.

@pbrocks
Last active October 10, 2018 00:21
Show Gist options
  • Save pbrocks/c6ea3f46a7d17895208fc0f9a102741e to your computer and use it in GitHub Desktop.
Save pbrocks/c6ea3f46a7d17895208fc0f9a102741e to your computer and use it in GitHub Desktop.
Custom Register Helper fields for Paid Memberships Pro
<?php // Do not include this or the doc block if adding to a Customizations plugin
/**
* Add this to its own folder in your plugins directory or copy the code below this doc block to a Customizations Plugin and customize to suit your needs.
*
* Plugin Name: PMPro Register Helper Examples
*
* Description: Create a folder name in your plugins' folder with the same name as this filename, but without the .php extension. Save this file in that folder and then you can activate this plugin in your WordPress dashboard,
*
* Author: pbrocks
* Author URI: https://github.com/pbrocks
*/
/**
* Default Profile Fields: First Name, Last Name, Email
*
* Text fields: Title, Organization, Industry
*
* Checkboxes: Advisory Board [Y/N], CISO [Y/N], Richmond Area [Y/N], InfraGard Member [Y/N], Help with Outreach [Y/N]
*
* [initialize_pmprorh_fields description]
*
* @return [type] [description]
*/
function initialize_pmprorh_fields() {
// 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(
'member_title',
'text',
array(
'label' => 'Title',
'size' => 40,
'profile' => true,
'memberslistcsv' => true,
'addmember' => true,
)
);
$fields[] = new PMProRH_Field(
'member_organization',
'text',
array(
'label' => 'Organization',
'size' => 40,
'profile' => true,
'memberslistcsv' => true,
'addmember' => true,
)
);
$fields[] = new PMProRH_Field(
'member_industry',
'text',
array(
'label' => 'Industry',
'size' => 40,
'profile' => true,
'memberslistcsv' => true,
'addmember' => true,
)
);
// CHECKBOX Advisory Board
$fields[] = new PMProRH_Field(
'advisory_board', // input name, will also be used as meta key
'checkbox', // type of field
array(
'label' => ucwords( preg_replace( '/_+/', ' ', 'advisory_board' ) ),
'text' => 'Check this', // string for <label></label>
'profile' => true,
'memberslistcsv' => true,
'addmember' => true,
'required' => false,
)
);
$fields[] = new PMProRH_Field(
'ciso', // input name, will also be used as meta key
'checkbox', // type of field
array(
'label' => 'CISO',
'text' => 'Customize this', // string for <label></label>
'profile' => true,
'memberslistcsv' => true,
'addmember' => true,
'required' => false,
)
);
$fields[] = new PMProRH_Field(
'richmond_area', // input name, will also be used as meta key
'checkbox', // type of field
array(
'label' => ucwords( preg_replace( '/_+/', ' ', 'richmond_area' ) ),
'text' => 'Customize this', // string for <label></label>
'profile' => true,
'memberslistcsv' => true,
'addmember' => true,
'required' => false,
)
);
$fields[] = new PMProRH_Field(
'infragard_member', // input name, will also be used as meta key
'checkbox', // type of field
array(
'label' => 'InfraGard Member',
'text' => 'Customize this', // string for <label></label>
'profile' => true,
'memberslistcsv' => true,
'addmember' => true,
'required' => false,
)
);
$fields[] = new PMProRH_Field(
'help_with_outreach', // input name, will also be used as meta key
'checkbox', // type of field
array(
'label' => ucwords( preg_replace( '/_+/', ' ', 'help_with_outreach' ) ),
'text' => 'Customize this', // string for <label></label>
'profile' => true,
'memberslistcsv' => true,
'addmember' => true,
'required' => false,
)
);
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', 'initialize_pmprorh_fields' );
@pbrocks
Copy link
Author

pbrocks commented Oct 10, 2018

View in Profile

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment