Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
192
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function populate_csv( $entry, $form ) {
  2.  
  3. //Headers info
  4. $headers = array('Nominee', 'Reason', 'Justification');
  5.  
  6. //Build form data
  7. $data = array(
  8. 'Nominee' => rgar( $entry, '1' ),
  9. 'Reason' => rgar( $entry, '4' ),
  10. 'Justification' => rgar( $entry, '3' )
  11. );
  12.  
  13. //Open or Create CSV File
  14. $fh = fopen('Nominations.csv', 'w');
  15.  
  16. //Create headers
  17. fputcsv($fh, $headers);
  18.  
  19. //Populate the data
  20. foreach($data as $fields){
  21. fputcsv($fh, $fields);
  22. }
  23.  
  24. //Close the file
  25. fclose($fh);
  26. }
  27. add_action( 'gform_after_submission_11', 'populate_csv', 10, 2 );
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement