Skip to content

Instantly share code, notes, and snippets.

@ronalfy
Created November 13, 2020 15:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ronalfy/236d64be66f4fcaa3fa6246683b238eb to your computer and use it in GitHub Desktop.
Save ronalfy/236d64be66f4fcaa3fa6246683b238eb to your computer and use it in GitHub Desktop.
PMPRo - Register Helper Restrict by Level
<?php
function my_pmprorh_init() {
// don't break if Register Helper is not loaded
if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
return false;
}
$fields = array();
$fields[] = new PMProRH_Field(
'besuchen_webinar',
'radio',
array(
'label' => 'Welches Webinar möchten Sie besuchen?',
'required' => true, // make field required, set value to false to make it optional
'profile' => true, // show in user profile
'options' => array(
'deutsch_friday' => 'DEUTSCH: Fr. 28.05.2021 (09-13.00)',
'deutsch_monday' => 'DEUTSCH: Mo. 29.11.2021 (09-13.00)',
'englisch_friday' => 'ENGLISCH: Friday 11 June, 2021 (09 am – 01 pm)',
'englisch_monday' => 'ENGLISCH: Monday 13 December, 2021 (09 am – 01 pm)',
),
'levels' => array( 3 ),
)
);
$fields[] = new PMProRH_Field(
'company', // input name, will also be used as meta key
'text', // type of field
array(
'label' => 'Company', // custom field label
'size' => 40, // input size
'class' => 'company', // custom class
'profile' => true, // show in user profile
'required' => true, // make this field required
'levels' => array( 3 ),
)
);
foreach ( $fields as $field ) {
pmprorh_add_registration_field(
'checkout_boxes', // location on checkout page
$field // PMProRH_Field object
);
}
}
add_action( 'init', 'my_pmprorh_init' );
add_action( 'init', 'my_register_helper_init' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment