Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
177
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. fputcsv($fh,$data);
  21.  
  22. //Close the file
  23. fclose($fh);
  24. }
  25. add_action( 'gform_after_submission_11', 'populate_csv', 10, 2 );
Advertisement
RAW Paste Data Copied
Advertisement