Skip to main content

See what the migration wizard made of an uploaded export, before anybody is imported

Premium Intermediate

The Migration Wizard’s upload step posts the podcaster’s export to POST /benecaster-migration-wizard/v1/shows/{show_id}/csv-preview and shows what comes back: the platform recognised from the headings, the columns as the file spelled them, and the first five rows. The benecaster_migration_csv_preview filter is where you add your own reading of the file — a column your CRM needs, or a warning about a value only you recognise. This recipe notes whether the export carries a member ID.

The parse is all there is. The uploaded file is read out of PHP’s temporary upload and discarded when the request ends. There is no stored copy, deliberately: a subscriber list left under wp-content outlives the wizard session and lands in every later backup.

Neutralise anything you put in preview or a columns heading with \BenecasterMigrationWizard\CsvParser::neutralise_formula(). Those values are shown in an admin table and reach the import report’s export, where a cell starting =, +, - or @ runs as a formula when opened in a spreadsheet. Neutralise at output only — doing it on the way in would store a tier genuinely named +1 Supporter with a quote stuck to the front for good.

Leave platform as null when it is null. That sends the podcaster to manual column mapping. A guess pre-fills a mapping nobody confirmed and moves an audience onto the wrong tiers.

Calling the route yourself: multipart, with the file under the field name file, an X-WP-Nonce header, and no Content-Type of your own — the boundary is the browser’s to generate. See Migration Wizard REST API.

Code

<?php
add_filter(
    'benecaster_migration_csv_preview',
    function ( array $payload, \BenecasterMigrationWizard\ParsedCsv $csv ): array {
        // The parse is all there is: the uploaded file is read out of PHP's
        // temporary upload and discarded when the request ends. There is no
        // stored copy to open, deliberately — a subscriber list left under
        // wp-content outlives the wizard session and lands in every backup.
        $payload['has_external_id'] = $csv->has_column( 'Member ID' );

        return $payload;
    },
    10,
    2
);

View on GitHub →

Hooks Used

Need this built rather than just documented? See our services →