Skip to content

Instantly share code, notes, and snippets.

@kimwhite
Forked from ipokkel/my_pmprorh_init.php
Last active August 24, 2021 17:03
Show Gist options
  • Save kimwhite/55f16b29dc92f9600920e3481409b8e7 to your computer and use it in GitHub Desktop.
Save kimwhite/55f16b29dc92f9600920e3481409b8e7 to your computer and use it in GitHub Desktop.
Sample RH custom fields
<?php
/*
Plugin Name: PMPro Customizations
Plugin URI: https://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Customizations for my Paid Memberships Pro Setup
Version: .1
Author: Paid Memberships Pro
Author URI: https://www.paidmembershipspro.com
*/
//Now start placing your customization code below this line
function my_pmprorh_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(
'biz_name', // input name, will also be used as meta key
'text', // type of field
array(
'label' => 'Business Name',
'html_attributes' => array( 'placeholder' => 'e.g., Example' ), // add valid html input field attributs
'hint' => 'This is a hint', // display a hint under field YOU CAN REMOVE THIS LINE IF NOT NEEDED
'levels' => array( 2,3 ), // restricts levels to display field for YOU CAN REMOVE THIS LINE IF NOT NEEDED
'class' => 'css_class_name', // custum class for input field YOU CAN REMOVE THIS LINE IF NOT NEEDED
'divclass' => 'css_class_name_for_div', // custom class for container div YOU CAN REMOVE THIS LINE IF NOT NEEDED
'size' => 40, // field width
'profile' => true, // show on profile
'memberslistcsv' => true, // include when using export members to csv
'addmember' => true, // include when using add member from admin
'required' => true, // make field required
)
);
$fields[] = new PMProRH_Field(
'contact_number', // input name, will also be used as meta key
'text', // type of field
array(
'label' => 'Contact Number',
'html_attributes' => array( 'placeholder' => 'e.g., Example' ), // add valid html input field attributs
'hint' => 'This is a hint', // display a hint under field YOU CAN REMOVE THIS LINE IF NOT NEEDED
'levels' => array( 2,3 ), // restricts levels to display field for YOU CAN REMOVE THIS LINE IF NOT NEEDED
'class' => 'css_class_name', // custum class for input field YOU CAN REMOVE THIS LINE IF NOT NEEDED
'divclass' => 'css_class_name_for_div', // custom class for container div YOU CAN REMOVE THIS LINE IF NOT NEEDED
'profile' => true, // show on profile
'memberslistcsv' => true, // include when using export members to csv
'addmember' => true, // include when using add member from admin
'required' => true, // make field required
)
);
foreach ( $fields as $field ) {
pmprorh_add_registration_field(
$field->location, // 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', 'my_pmprorh_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment