Skip to main content

Inject a step into the setup wizard from an add-on

Free Intermediate Since v1.0.0

Add-ons inject additional wizard steps by appending entries to the steps array. Each step entry must include id, component (React component registered on window.BenecasterExtensions), required, and condition (a state flag string or null). The wizard re-evaluates and re-numbers active steps whenever state changes. A step with an unrecognised condition defaults to inactive — safe to deploy before the flag-setting logic exists.

Code

<?php
add_filter( 'benecaster_setup_wizard_steps', function ( array $steps ): array {
    // Insert after the 'subscription' step.
    $insert_after = array_search( 'subscription', array_column( $steps, 'id' ), true );
    if ( false !== $insert_after ) {
        array_splice( $steps, $insert_after + 1, 0, [[
            'id'        => 'my-addon-config',
            'component' => 'MyAddonWizardStep',
            'required'  => false,
            'condition' => 'bridge_connected',
        ]] );
    }
    return $steps;
} );

View on GitHub →

Hooks Used