eventsmanager icon

Custom Booking Summary Column For File Upload

eventsmanager | PRO | 02/23/25 02:52:18 PM UTC (Edited) | 0 ⭐ | 324 👁️ | Never ⏰ | []
text |

1.17 KB

|

None

|

0 👍

/

0 👎

<?php
 /**
 * Replace "passport" with your forms editor Field ID
 * Choose "File Upload" field in the "Bookings Table Settings" dialog
 */
function my_em_bookings_table_cols_template_file_upload($template, $EM_Bookings_Table){
    $template['file_upload'] = 'File Upload';
    return $template;
}
add_action('em_bookings_table_cols_template', 'my_em_bookings_table_cols_template_file_upload',10,2);
 function my_em_custom_booking_form_cols_file_upload($val, $col, $EM_Booking, $EM_Bookings_Table, $csv){
     if( $col == 'file_upload' ){
 		$booking_meta = $EM_Booking->booking_meta['booking'];
 		$uploaded = $booking_meta['passport']['files'];
		$fileURL = "";
		foreach( $uploaded as $key => $value ){
			$files = $uploaded[$key];
			foreach( $files as $File_key => $File_val ){
				if ( $File_key == 'url' ){
					$fileURL = $File_val;
				}
			}
		}
        $val =  ( !empty( $uploaded ) ) ? '<a href="'.$fileURL.'" class="button button-secondary" target="_blank">View/Download</a>':'N/A';
		EM_Bookings_Table::$cols_allowed_html[$col] = true;
    }
    return $val;
}
add_filter('em_bookings_table_rows_col','my_em_custom_booking_form_cols_file_upload', 100, 5);

Comments