Advertisement
Guest User

Untitled

a guest
Dec 12th, 2018
96
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', 'Reason1', 'Reason2', 'Reason3', 'Justification');
  5.  
  6.     //Build form data
  7.     $data = array(
  8.         'Nominee' => rgar( $entry, '1' ),
  9.         'Reason1' => rgar( $entry, '4.1' ),
  10.         'Reason2' => rgar( $entry, '4.2' ),
  11.         'Reason3' => rgar( $entry, '4.3' ),
  12.         'Justification' => rgar( $entry, '3' ),
  13.                  );
  14.    
  15.     //Open or Create CSV File
  16.     $fh = fopen('Nominations.csv', 'a');       
  17.  
  18.     //Create headers
  19.     fputcsv($fh, $headers);
  20.  
  21.     //Populate the data
  22.     fputcsv($fh,$data);
  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