Created
February 12, 2020 10:18
-
-
Save andrewlimaza/5f4f6009ef440f7b96e8b65523cc5bdb to your computer and use it in GitHub Desktop.
Register Helper Webinar Example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Comments to be updated. | |
* | |
*/ | |
function my_pmpro_rh_fields() { | |
// Don't break if Register Helper is not loaded. | |
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) { | |
return false; | |
} | |
// $fields array for Register Helper Example. | |
$fields = array(); | |
$fields[] = new PMProRh_Field( | |
'company_name', // meta key or name | |
'text', // field type | |
array( | |
'label' => 'Company Name', | |
'required' => true, | |
'levels' => array(1), | |
'profile' => true | |
) | |
); | |
$fields[] = new PMProRh_Field( | |
'favorite_color', // meta key or name | |
'select', // field type | |
array( | |
'label' => 'Please select a favorite color', | |
'required' => false, | |
'profile' => true, | |
'options' => array( | |
'' => 'Please choose a color', | |
'red' => 'Red', | |
'blue' => 'Blue', | |
'green' => 'Green' | |
) | |
) | |
); | |
$fields[] = new PMProRh_Field( | |
'telephone', // meta key or name | |
'text', // field type | |
array( | |
'label' => 'Telephone Number', | |
'required' => true, | |
'profile' => true | |
) | |
); | |
$fields[] = new PMProRh_Field( | |
'my_user_notes', // meta key or name | |
'textarea', // field type | |
array( | |
'label' => 'Please add general notes about the user to this field.', | |
'profile' => 'only_admin' | |
) | |
); | |
// Add the fields into a new checkout_boxes are of the checkout page. | |
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', 'my_pmpro_rh_fields' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment