eventsmanager

Custom Booking Summary Column For File Upload

Feb 23rd, 2025 (edited)
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.17 KB | None | 0 0
  1. <?php
  2.  
  3. /**
  4. * Replace "passport" with your forms editor Field ID
  5. * Choose "File Upload" field in the "Bookings Table Settings" dialog
  6. */
  7. function my_em_bookings_table_cols_template_file_upload($template, $EM_Bookings_Table){
  8. $template['file_upload'] = 'File Upload';
  9. return $template;
  10. }
  11. add_action('em_bookings_table_cols_template', 'my_em_bookings_table_cols_template_file_upload',10,2);
  12.  
  13. function my_em_custom_booking_form_cols_file_upload($val, $col, $EM_Booking, $EM_Bookings_Table, $csv){
  14.  
  15. if( $col == 'file_upload' ){
  16.  
  17. $booking_meta = $EM_Booking->booking_meta['booking'];
  18.  
  19. $uploaded = $booking_meta['passport']['files'];
  20. $fileURL = "";
  21. foreach( $uploaded as $key => $value ){
  22. $files = $uploaded[$key];
  23. foreach( $files as $File_key => $File_val ){
  24. if ( $File_key == 'url' ){
  25. $fileURL = $File_val;
  26. }
  27. }
  28. }
  29. $val = ( !empty( $uploaded ) ) ? '<a href="'.$fileURL.'" class="button button-secondary" target="_blank">View/Download</a>':'N/A';
  30. EM_Bookings_Table::$cols_allowed_html[$col] = true;
  31. }
  32. return $val;
  33. }
  34. add_filter('em_bookings_table_rows_col','my_em_custom_booking_form_cols_file_upload', 100, 5);
Advertisement
Add Comment
Please, Sign In to add comment