Need some help as I have very basic knowledge of code and not sure I understand what i need to.
I have been given two sets of codes from a wordpress plugin support that they say will help me do what I need to do
My goal is to have a table that display different data and headers based on a field called attendee form (each attendee form has different fields).
They have given me the two codes.
First one displays a table but I have had to manually enter each table header and it is not dynamic
function my_attendee_form (){
$people = array();
$EM_Bookings = $EM_Event->get_bookings();
if( count($EM_Bookings->bookings) > 0 )
{
echo "
";
?>
<table class="event-attendees">
<tr class="">
<th class="attendee-name">Name</th>
<th class="attendee-country">Golf Link</th>
<th class="attendee-discipline">Handicap</th>
<th class="attendee-status">Home Club</th>
</tr>
<?php
$guest_bookings = get_option('dbem_bookings_registration_disable');
$guest_booking_user = get_option('dbem_bookings_registration_user');
$counter = 0;
foreach( $EM_Bookings as $EM_Booking){
$attendees_list = "";
$attendees = $EM_Booking->booking_meta['attendees'];
if ( !empty($attendees) ) {
$attendees_list = "";
foreach($attendees as $key => $value) {
foreach($value as $key_attendee => $value_attendee) {
$attendees_list .= "<tr>";
$attendees_list .= "<td>".$value_attendee["attendee_name"]."</td>";
$attendees_list .= "<td>".$value_attendee["golflink"]."</td>";
$attendees_list .= "<td>".$value_attendee["handicap"]."</td>";
$attendees_list .= "<td>".$value_attendee["home_club"]."</td>";
$attendees_list .= "</tr>";
}
}
}
echo $attendees_list;
}
echo "
";
?>
</table>
<?php
}
if( count($EM_Bookings->bookings) == 0 )
{
echo '<p>No one registered yet... Will you be the first ?</p>'};
}
add_action('em_bookings_event_footer', 'my_attendee_form');
This is slightly broken, the table works.
The second bit of code adds a column to an existing table and populates it based on the form fields.
function my_em_bookings_table_cols_template_attendee2($template, $EM_Bookings_Table){
$template['attendee_name'] = 'Attendee Name';
return $template;
}
add_action('em_bookings_table_cols_template', 'my_em_bookings_table_cols_template_attendee2',10,2);
function my_em_custom_booking_form_cols_attendee_list($val, $col, $EM_Booking, $EM_Bookings_Table, $csv){
if( $col == 'attendee_name' ){
$EM_Tickets_Bookings = $EM_Booking->get_tickets_bookings();
$attendee_datas = EM_Attendees_Form::get_booking_attendees($EM_Booking);
$attendee_list = "";
foreach( $EM_Tickets_Bookings->tickets_bookings as $EM_Ticket_Booking ){
//Display ticket info
if( !empty($attendee_datas[$EM_Ticket_Booking->ticket_id]) ){
$val .= "<ul>";
$val .= "<li> <strong>Ticket name: ".$EM_Ticket_Booking->get_ticket()->ticket_name."</strong></li>";
foreach( $attendee_datas[$EM_Ticket_Booking->ticket_id] as $attendee_title => $attendee_data ){
$val .= "<li>".$attendee_title."</li>";
$val .= "<li><ul>";
foreach( $attendee_data as $field_label => $field_value){
$val .= "<li>". $field_label .': '.$field_value."</li>";
}
$val .= "</ul></li>";
}
$val .= "<ul>";
}
}
}
return $val;
}
add_filter('em_bookings_table_rows_col','my_em_custom_booking_form_cols_attendee_list', 10, 5);
How would I combine these two so that I can generate a new table like the first code, but populate it like the second one? I just don't know what goes where.
Any suggestions/thoughts would be great.
Thanks Troy