Hook: mam_wizard_app_bases (onboarding path for a core plugin)

Purpose

The App Setup Wizard sets up a new app at install: its navigation and its home screen. What it sets up depends on the main plugin the app is built on, the app base. mam-main detects which bases are active and sends the admin down that base’s steps:

  • One base active: straight down its path.
  • Several active: the welcome step asks “What kind of app are you building?”. The choice is saved in the option mam_wizard_app_base.
  • None active: the same question lists every registered base. Picking one installs and activates its core plugin from WordPress.org, then its MAM plugin from the MAM software feed, then continues down that path.

Every path is install-only. Once an app has a navigation, the wizard does not change it; App Navigation and App Settings handle changes from then on.

Each MAM core plugin registers its own path through this filter. mam-main registers geodirectory and buddypress itself; mam-business-directory, mam-awp-classifieds, mam-events-manager, mam-woocommerce and mam-support-candy register theirs.


Signature

add_filter( 'mam_wizard_app_bases', function ( array $bases ) {
    $bases['business-directory'] = array(
        'active' => is_plugin_active( 'business-directory-plugin/business-directory-plugin.php' ),
        'steps'  => array(
            'bd_home' => array(
                'name'   => __( 'Home Screen Setup', 'my-textdomain' ),
                'title'  => __( 'Home Screen', 'my-textdomain' ),
                'render' => 'my_bd_render_home_step', // function ( bool $complete ): string
            ),
        ),
    );
    return $bases;
} );

The filter starts as an empty array. mam-main merges your entry over its own catalog entry for the same key (top-level keys replace; steps replaces as a whole), so you only need the keys you change. Add the filter on plugins_loaded (any priority) or earlier. The wizard page reads it at init or later, so every base registered on plugins_loaded is in the step list.

Keys

Key Type Meaning
label string Card title, e.g. “Business Directory app”.
desc string One-line use case under the title.
order int Card order, lower first.
active bool The core plugin is detected. Use is_plugin_active(), class_exists() or defined() only. When left out, mam-main checks is_plugin_active( core_plugin.file ).
core_plugin array name, file (e.g. business-directory-plugin/business-directory-plugin.php), wporg_slug. Used to install the core from WordPress.org on a site that has none.
mam_plugin array slug, name (optional file, default slug/slug.php). The MAM plugin that brings this path. When the core is active but this plugin is not, the welcome step offers the install from the MAM software feed.
steps array step_key => array( name, title, render ). render is a callable function ( bool $complete ): string that returns the step HTML. mam-main puts these steps between app_welcome and the shared branding, app_previewer and next_steps steps. Reserved keys (app_welcome, branding, app_previewer, next_steps) are ignored. Prefix your keys with your base (bd_home, wc_nav).
branding callable Optional. Replaces the shared Colors and Branding step.
welcome callable Optional. Replaces the generic welcome (core status, MAM plugin install, Next).
next_steps_note string Optional. The “Add more features” line on the last step (HTML allowed).
welcome_note string Optional. A line under “Great news! … is installed and active” on the standard welcome step (HTML allowed). Declared in mam-main’s catalog for bases whose welcome shows before their MAM plugin is installed.
welcome_count array Optional. post_types (array of post type names), found (a line with %s for the number, HTML allowed) and none (the line when there are none). The standard welcome step counts the published posts of those types and shows one of the two lines, so the site owner knows before previewing whether the app will have content. Declared in mam-main’s catalog for bases whose welcome shows before their MAM plugin is installed (Business Directory counts wpbdp_listing).
step_overrides array Optional. app_previewer and/or next_steps => array( name, title, render ): the base draws that shared step itself (for example the SupportCandy path when the site uses the WPMAM Support app). render is a callable returning HTML; name and title default to the shared step’s. A next_steps override must end with its own Finish link (skip-mam-wizard=1).
return_page string Optional. Admin page slug Finish lands on. Default: App Features, on the base MAM plugin’s tab when that plugin registers features (see mam_feature_wizards), else the Overview.
optional_nav array Optional. Buttons (same shape as mam_wizard_apply_nav()) another path may offer as optional tabs when this base is active but not the one the app is built on. Read with mam_wizard_optional_nav_items( $selected_base ).

Reserved keys and the catalog

Key Core plugin MAM plugin
geodirectory GeoDirectory mam-geodirectory (path in mam-main)
buddypress BuddyPress / BuddyBoss mam-buddypress (path in mam-main)
business-directory Business Directory Plugin mam-business-directory
woocommerce WooCommerce mam-woocommerce
awp-classifieds AWP Classifieds mam-awp-classifieds
events-manager Events Manager mam-events-manager
supportcandy SupportCandy mam-support-candy

mam-main ships the label, description, core plugin and MAM plugin of all seven, so the selector works before any MAM core plugin is installed, and activating any of these core plugins on an app with no navigation offers the wizard again. Business Directory, AWP Classifieds and Events Manager also carry their welcome_count in the catalog (wpbdp_listing, awpcp_listing, event).

When a base is offered

A base is routed to when it is active and has steps. A base without steps whose MAM plugin is not active yet is routed to only when it is the only active base (its welcome then offers the MAM plugin install). Next to another active base it is not routed to; the no-base selector offers its MAM plugin install instead. A base whose core and MAM plugin are both active but which registers no steps (an older MAM plugin) is never routed to; on the no-base selector its card says an update is needed.


Writing a step

A step returns its HTML and moves on with a link. Helpers:

  • mam_wizard_step_url( $step ): URL of a step.
  • mam_wizard_next_step_url( $step ): URL of the step after $step in the list in force.
  • mam_wizard_current_app_base(): the base this run is on.

Steps that write do it through your own nonce’d wp_ajax_ handler (check manage_options), called from the step’s script before it follows the Next link. The BuddyPress path (mam_wizard_bp_apply) is the example.


Shared helpers

All are global functions in mam-main (guarded with function_exists).

mam_wizard_app_already_configured( $role = 'mam-all' ): bool

For mam-all (the app as a whole): true when mam-all holds a button other than Login / Logout, or app role management is on and any WordPress role holds such a button. For another role: true when that role holds such a button. Every path uses this one rule. Show mam_wizard_already_configured_message() and skip your writes when it is true.

A re-run is allowed only over a nav the wizard built for the same base and nobody changed since (mam_wizard_can_rerun( $base, $role ), or mam_wizard_can_rerun_base( $base ) for a path that builds several roles). mam_wizard_apply_nav() records it for you, after its own writes, whenever it created a button or ran as a re-run, so a path does not record it itself. Build each role’s nav in one mam_wizard_apply_nav() call; buttons added or reordered outside it afterwards count as a change, and a re-run is then refused. (mam_wizard_record_applied( $base, $roles ) is what it calls.)

mam_wizard_apply_nav( array $buttons, $role = 'mam-all', array $args = array() ): array

Creates buttons through the configurator engine (MAM_Config_Apply), in the order given: append-only, with an undo snapshot. A button is created only when no button of that type exists on that role and location.

Several screens of one type, such as one screen per product category, go in the same call, each with its own source (and its own name: the engine matches existing buttons on name and type). When a call passes more than one button of a type on one location, each of them is created only when no button of that type with that source exists there. A call with one button of a type keeps matching on type alone, unless the type is listed in $args['match_source'] (an array of types, 26.43.3+): those always match on type and source, so a re-run that swaps one category for another creates the new screen.

A HomeForTabbar button also gets the tag cloud colors, the screen title (site name) and position 0. JSON caching is left as it was.

Check function_exists( 'mam_wizard_api_version' ) && version_compare( mam_wizard_api_version(), '26.43.3', '>=' ) before registering a base that relies on match_source (mam-main 26.43.3+; older builds have no such function).

Buttons: array( 'name' => 'Directory', 'type' => 'BusinessDirectory', 'location' => 'main' | 'left', 'source' => '', 'icon' => optional URL, 'settings' => optional array( variable => value ) ).

$args: base (your base key; recorded so a re-run can be recognised), rerun (true to allow a re-run over a nav this wizard built for the same base and nobody changed since), force (skip the guard; only inside a write your path already guarded), screen_title. JSON caching on $role is left as it was.

Refuses, writing nothing, when the role is already configured and it is not such a re-run.

Returns:

Key Type Meaning
refused bool Nothing was written because the app is already configured.
created int Buttons created.
existing int Requested buttons that already existed (same type, or same type and source when the call passes that type more than once).
button_ids array type => button id of the first button of every requested type that exists afterwards.
buttons array One row per requested button, in call order: name, type, location, source, id ('' when it could not be created). Use it to find each of several same-type buttons.
undo_snapshot_id int Snapshot to roll back with (MAM_Config_Apply::rollback()), 0 when none covers the role.
notes string[] Informational.
errors string[] Customer-readable failures.

mam_wizard_create_home_button( $role = 'mam-all', array $args = array() ): string

Creates the Home (HomeForTabbar) button with tag cloud colors, screen title and position 0, or returns the existing one untouched. $args: name, icon, screen_title, plus the guard keys force / base / rerun. Guarded: on an app that is already configured it creates nothing and returns '' unless force (or base + rerun on the wizard’s own nav). Also '' when the nav is locked.

mam_wizard_save_home_stack( array $sections, $role = 'mam-all', array $args = array() ): bool

mam_wizard_save_home_stack( array(
    array( 'type' => 'bottom_tabbar' ),
    array( 'type' => 'listing_search' ),
    array( 'type' => 'filter_bar', 'settings' => array( 'mam-hs-filter-bar-section-type' => 'single' ) ),
    array( 'type' => 'listing_table' ),
) );

Settings keys are the stored mam-hs-* keys, written as given. nav_header is dropped (the app always gets one). A filter_bar without a background color gets the dark theme color. When the role has no home stack yet, the sections are saved as given. Otherwise only section types the stack does not have yet are added, ahead of a trailing tab bar; nothing is removed or reordered. Returns true when saved.

Guarded like mam_wizard_create_home_button(). Your own mam_wizard_apply_nav() call makes the app “configured”, so call this right after it with array( 'force' => true ), and only when that apply was not refused:

$nav = mam_wizard_apply_nav( $buttons, 'mam-all', array( 'base' => 'business-directory', 'rerun' => true ) );
if ( ! $nav['refused'] && empty( $nav['errors'] ) ) {
    mam_wizard_save_home_stack( $sections, 'mam-all', array( 'force' => true ) );
}

mam_wizard_apply_branding( $base, $role = '', array $button_ids = array() ): bool

Carries the colors chosen on the branding step onto the app the wizard built: tag cloud colors on the Home button (and $button_ids), the dark color as the filter bar background. Tab bar and other colors already follow the theme colors. $role '' means every role the wizard recorded for $base (mam-all and any member roles your path built through mam_wizard_apply_nav()). Only runs on roles whose nav the wizard built for $base and nobody changed since. Returns true when at least one role was recolored. The shared branding step calls it for you.

mam_wizard_enable_signed_in_role( $base ): string (26.49.23+)

Turns sign-in and sign-up on, so your path can build a menu for signed-in people (a My Tickets tab, say) on a site that has no signed-in app role yet. It runs the App Features “Sign-in and sign-up” row’s own setters, so the app ends up exactly as when the owner saves that row with its offered answers:

  • A Login button in the logged-out left menu, with “Anyone, and people can sign in” (Require Login off; left on when it is already on).
  • People can create an account in the app (mam_login_only = no). Email confirmation and Apple / Google sign-in keep their current answers, written explicitly. The role new accounts get (default Subscriber) is written again only when it is one the row offers (a role that can read, not administrator).
  • “All other logged-in users” (mam-logged-in) on. Its menu starts as a copy of the logged-out menu without the Login button, or, when the logged-out menu holds only Login and the site has managed roles, a copy of the first managed role’s menu.

It adds no Logout and no other button. It records mam-logged-in as built by $base, so build that role’s menu right after it like any other role: mam_wizard_apply_nav( $buttons, 'mam-logged-in', array( 'base' => $base, 'rerun' => true ) ) and mam_wizard_save_home_stack() with the same args. It writes nothing to WordPress’s own registration settings (users_can_register, default_role), creates no page and sends no email. It does let anyone create a WordPress user account on the site from the app, so say so in your step.

Guarded, before anything is written: it only runs on an app with no navigation, or on a re-run of $base over the nav the wizard built for it and nobody changed since (it then refreshes that record, since a Login button may have been added). It also refuses when mam-logged-in already holds a menu built or changed outside the wizard: that role’s buttons stay stored while “All other logged-in users” is off, and turning it on would bring them back. In that case tell the owner that signed-in members already have their own menu and where to add your screen. Returns mam-logged-in when that role is on afterwards, '' when refused or not saved. Check function_exists( 'mam_wizard_api_version' ) && version_compare( mam_wizard_api_version(), '26.49.23', '>=' ) first, and on an older mam-main tell the owner to turn sign-in on with the “Sign-in and sign-up” row instead.

Others

  • mam_wizard_get_app_bases(), mam_wizard_active_app_bases(): the normalized registry (all, or routable).
  • mam_wizard_optional_nav_items( $selected_base ): other active bases’ optional_nav.
  • mam_wizard_nav_is_empty(): no role has a button other than Login / Logout.

When the wizard is offered

  • On the first admin page load after mam-main is activated (unchanged).
  • Again when a registered core plugin is activated and no role has a navigation yet: the setup reminder comes back, and after a single activation from the Plugins screen the admin is taken to the wizard once (GET page loads only). When the core plugin has its own setup screen (WooCommerce, BuddyPress, GeoDirectory), that screen wins and only the reminder comes back. Bulk activation, WP-CLI, AJAX and cron activations only bring the reminder back.
  • A core plugin installed from the wizard’s selector does not take over the reload: its activation redirect is cleared and the wizard continues.

Metadata

Field Value
Article type Hook Reference
Plugin slug mam-main
Applies to plugin version 26.43.2+ (beta)
Category Extending MAM Suite
Hook type filter
Audience PHP developer / integrator
Last verified 2026-12-03
Was this article helpful?
Contents

    Need Support?

    Can't find the answer you're looking for? Don't worry we're here to help!