Page Builder Summit Limited Time Offer - 20% OFF! Use coupon PBS20 - View Details

Add PDF Links to Submissions CSV Exports

It is possible to add links (URLs) to submission PDF exports using the WS Form wsf_submit_export_csv_header and wsf_submit_export_csv_row filter hooks.

Sample code for doing so can be found below:

// Add a callback function for the wsf_submit_export_csv_row filter hook
add_filter( 'wsf_submit_export_csv_header', 'wsf_submit_export_csv_header_function', 10, 2 );

// Callback function for the wsf_submit_export_csv_header filter hook
function wsf_submit_export_csv_header_function( $csv_header, $form_id ) {

    // Add PDF URL to CSV export header
    $csv_header['pdf_url'] = __('PDF URL', 'ws-form');

    // Return key value pairs array for CSV header
    return $csv_header;
}

// Add a callback function for the wsf_submit_export_csv_row filter hook
add_filter( 'wsf_submit_export_csv_row', 'wsf_submit_export_csv_row_function', 10, 3 );

// Callback function for the wsf_submit_export_csv_row filter hook
function wsf_submit_export_csv_row_function( $csv_row, $form_id, $submit ) {

    // Create instance of the PDF action class
    $ws_form_action_pdf = new WS_Form_Action_PDF();

    // Get PDF URL
    $pdf_url = $ws_form_action_pdf->get_pdf_url(

        $submit->hash,     // Submission hash
        $form_id,          // Form ID
        true               // Download (true = Yes, false = No)
    );

    // Add PDF URL to CSV row
    $csv_row['pdf_url'] = $pdf_url;

    // Return key value pairs array for CSV row
    return $csv_row;
}