Skip to main content

benecaster_run_as_import()

Feed Token Free
benecaster_run_as_import( callable $work ): mixed

Runs $work as an import: every token written inside it reports benecaster_is_import() true to listeners on the token actions. For an add-on that brings listeners over from another platform, as the Migration Wizard does, so other integrations can tell them from new signups.

Parameters

Name Type Default Required Description
$work callable — Yes The code that writes the imported listener's token.

Return Value

Type: mixed

Whatever $work returns.

Example

$token = benecaster_run_as_import(
    fn() => $token_manager->generate( $user_id, $show_id, $tier_slug, 'subscriber', $joined_at )
);

Notes

Wrap the token write itself, not a whole request. The answer goes back to what it was when $work returns or throws, and a nested call does not end the outer one.

It changes nothing Benecaster does with the token: the welcome email, analytics and counts are as for any token.

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