Created
June 2, 2025 18:19
-
-
Save jonschr/8668876ca98e8cba44e8799c30749a49 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
function prf_register_repeater_first_name( $form_id ) { | |
return GF_Fields::create( array( | |
'type' => 'text', | |
'id' => 1001, // The Field ID must be unique on the form | |
'formId' => $form_id, | |
'label' => 'First Name', | |
'pageNumber' => 1, // Ensure this is correct | |
'isRequired' => true, | |
'cssClass' => 'registrant-first-name', | |
) ); | |
} | |
function prf_register_repeater_last_name( $form_id ) { | |
return GF_Fields::create( array( | |
'type' => 'text', | |
'id' => 1002, // The Field ID must be unique on the form | |
'formId' => $form_id, | |
'label' => 'Last Name', | |
'pageNumber' => 1, // Ensure this is correct | |
'isRequired' => true, | |
'cssClass' => 'registrant-last-name', | |
) ); | |
} | |
function prf_register_repeater_email( $form_id ) { | |
return GF_Fields::create( array( | |
'type' => 'email', | |
'id' => 1003, // The Field ID must be unique on the form | |
'formId' => $form_id, | |
'label' => 'Email', | |
'pageNumber' => 1, // Ensure this is correct | |
'isRequired' => true, | |
'cssClass' => 'registrant-email', | |
) ); | |
} | |
function prf_register_repeater_phone( $form_id ) { | |
return GF_Fields::create( array( | |
'type' => 'phone', | |
'id' => 1004, // The Field ID must be unique on the form | |
'formId' => $form_id, | |
'label' => 'Phone', | |
'pageNumber' => 1, // Ensure this is correct | |
'isRequired' => true, | |
'cssClass' => 'registrant-phone', | |
) ); | |
} | |
function prf_register_repeater_role( $form_id, $conference_settings = null ) { | |
// Build role choices from conference settings or use fallback | |
$role_choices = array(); | |
if ( $conference_settings && isset( $conference_settings['conference_ticketed_roles'] ) && is_array( $conference_settings['conference_ticketed_roles'] ) ) { | |
// Use dynamic role data from conference settings | |
foreach ( $conference_settings['conference_ticketed_roles'] as $role ) { | |
if ( isset( $role['role_label'], $role['role_unique_identifier'], $role['role_ticket_price'] ) ) { | |
$role_choices[] = array( | |
'text' => esc_html( $role['role_label'] . ' - $' . number_format( $role['role_ticket_price'], 0 ) ), | |
'value' => esc_html( $role['role_unique_identifier'] . ', ' . $role['role_ticket_price'] ), | |
); | |
} | |
} | |
// Add Guest option (always free) | |
$role_choices[] = array( | |
'text' => 'Guest - $0', | |
'value' => 'guest, 0', | |
); | |
} | |
return GF_Fields::create( array( | |
'type' => 'select', | |
'id' => 1005, // The Field ID must be unique on the form | |
'formId' => $form_id, | |
'label' => 'Role', | |
'pageNumber' => 1, // Ensure this is correct | |
'isRequired' => true, | |
'cssClass' => 'registrant-role', | |
'placeholder' => 'Select a role', | |
'choices' => $role_choices, | |
) ); | |
} | |
function prf_register_repeater_events( $form_id, $conference_settings = null ) { | |
// Build event choices from conference settings or use fallback | |
$event_choices = array(); | |
if ( $conference_settings && isset( $conference_settings['conference_paid_events_guest_prices'] ) && is_array( $conference_settings['conference_paid_events_guest_prices'] ) ) { | |
// Use dynamic event data from conference settings | |
foreach ( $conference_settings['conference_paid_events_guest_prices'] as $event ) { | |
if ( isset( $event['event_label'], $event['event_unique_identifier'], $event['event_price'] ) ) { | |
$event_choices[] = array( | |
'text' => esc_html( $event['event_label'] . ' - $' . number_format( $event['event_price'], 0 ) ), | |
'value' => esc_html( $event['event_unique_identifier'] . ', ' . $event['event_price'] ), | |
); | |
} | |
} | |
} | |
// here's a var_dump of the event choices: | |
// /Users/jonschroeder/Local Sites/phenix-events/app/public/wp-content/plugins/phenix-events-functionality/lib/field-registration-repeaters.php:102: | |
// array (size=3) | |
// 0 => | |
// array (size=2) | |
// 'text' => string 'Opening Night at Knibbe Ranch - $250' (length=36) | |
// 'value' => string 'opening_night, 250' (length=18) | |
// 1 => | |
// array (size=2) | |
// 'text' => string 'Lunch 3/16/26 - $105' (length=20) | |
// 'value' => string 'lunch_3_16_26, 105' (length=18) | |
// 2 => | |
// array (size=2) | |
// 'text' => string 'Awards Reception - $235' (length=23) | |
// 'value' => string 'awards_reception, 235' (length=21) | |
return GF_Fields::create( array( | |
'type' => 'checkbox', | |
'id' => 1006, // The Field ID must be unique on the form | |
'formId' => $form_id, | |
'label' => 'Events', | |
'isRequired' => false, | |
'cssClass' => 'registrant-events hidden', | |
'choices' => $event_choices, | |
) ); | |
} | |
function prf_register_repeater_events_textbox( $form_id ) { | |
return GF_Fields::create( array( | |
'type' => 'text', | |
'id' => 1007, // The Field ID must be unique on the form | |
'formId' => $form_id, | |
'label' => 'Events', | |
'isRequired' => false, | |
'cssClass' => 'registrant-events-textbox', | |
'visibility' => 'hidden', // Hide this field by default | |
) ); | |
} | |
function prf_register_repeater_conference_identifier( $form_id, $conference_settings = null ) { | |
// Get the conference unique identifier from settings or use fallback | |
$conference_identifier = ''; | |
if ( $conference_settings && isset( $conference_settings['conference_unique_identifier'] ) ) { | |
$conference_identifier = $conference_settings['conference_unique_identifier']; | |
} | |
return GF_Fields::create( array( | |
'type' => 'hidden', | |
'id' => 1008, // The Field ID must be unique on the form | |
'formId' => $form_id, | |
'label' => 'Conference Identifier', | |
'defaultValue' => esc_html( $conference_identifier ), | |
'cssClass' => 'registrant-conference-identifier', | |
) ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment