Last active
June 8, 2021 20:40
-
-
Save andrewlimaza/7bec517d58ec07d55c166b73b83501fb to your computer and use it in GitHub Desktop.
Register Helper Depends 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 | |
//we have to put everything in a function called on init, so we are sure Register Helper is loaded | |
function my_pmprorh_init() | |
{ | |
//don't break if Register Helper is not loaded | |
if(!function_exists( 'pmprorh_add_registration_field' )) { | |
return false; | |
} | |
$fields[] = new PMProRH_Field( | |
'newsletter_1', | |
'checkbox', | |
array( | |
'label' => 'Newsletter 1 example', | |
'profile' => true, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'newsletter_2', | |
'checkbox', | |
array( | |
'label' => 'Newsletter 2 example', | |
'profile' => true, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
'newsletter_other', | |
'checkbox', | |
array( | |
'label' => 'Other, show options', | |
'profile' => true, | |
) | |
); | |
$fields[] = new PMProRH_Field( | |
"emails", | |
"checkbox_grouped", | |
array( | |
"depends" => array( array( 'id' => 'newsletter_other', 'value' => '1' ) ), | |
"label" => "Please tick which emails you would like to receive from us:", | |
"required" => true, | |
"memberslistcsv" => true, | |
"profile" => true, | |
"options" => array( | |
"newsletter" => "Newsletter signup", | |
"noemail" => "I do not want to receive any emails" | |
) | |
) | |
); | |
//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_pmprorh_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment