By default scheduled CSV exports have an autogenerated name, but occasionally you may need to control this name, or have it generated according specific logic. There are filters available that allow you to override the default filename of the generated file. The example below shows how to override the filename such that the file is always called “custom_filename.csv” – of course you can carry out any logic you like to decide on the filename – just make sure that you return a full path, not just the filename.

function ses_wpscd_scheduled_export_filename ( $filename ) {

    // Split the full path into the individual folders / filename
    $split_filename = explode( '/', $filename );

    // Drop the current filename
    array_pop( $split_filename );

    // Add the filename we want
    $split_filename[] = 'custom_filename.csv';

    // Merge the array back into a string again
    $new_filename = implode( '/', $split_filename );

    return $new_filename;
add_filter( 'ses_wpscd_scheduled_export_filename', 'ses_wpscd_scheduled_export_filename' );

This entry was posted in .
Bookmark the permalink.