Integration: Account code and enrollment server

Summary

MAM_Account_Code_Manager (includes/account-code/class-mam-account-code-manager.php) is the centralized accessor for the site’s account code — the customer enrollment ID that ties a WordPress site to a customer record on the WPMAM (Tiny Screen Labs) enrollment server.

The canonical storage key is now mam-account-code (migrated from local-app-account_code). The legacy key local-app-account_code is a frozen public contract kept working transparently via an alias filter registered in mam-main.php: ~2K customer sites have a value persisted, the mobile apps reference it, and the publish pipeline depends on it.


Public API

// Read (empty string if unset; falls back to the legacy key pre-migration)
$code = MAM_Account_Code_Manager::get();

// Write (only legitimate write path)
MAM_Account_Code_Manager::set( $new_code );

// Remove the stored code (site reset / staging clone reset) — clears both keys
MAM_Account_Code_Manager::delete();

// Whether any code is stored (the LOCALHOST sentinel counts as "set")
$has = MAM_Account_Code_Manager::exists();

// Whether the stored value is the offline sentinel
$offline = MAM_Account_Code_Manager::is_localhost_sentinel();

All reads/writes go through this class. Direct get_option('local-app-account_code') reads still work (legacy callers do this everywhere) but writes must go through the manager.


Enrollment server handshake

The setup wizard (includes/setup-wizard/mam-site-enrollment.php) handles the initial enrollment:

  1. POST to the WPMAM enrollment endpoint with the site URL
  2. Receive the assigned account code
  3. MAM_Account_Code_Manager::set( $assigned_code ) persists it
  4. Set local-app-onboarding-status to track wizard progress

Subsequent verifications (on the publish page, on plugin entitlement checks) compare the local value against what WPMAM has on file.


Read caching

MAM_Account_Code_Manager::get() is a thin wrapper over get_option( 'mam-account-code' ) with a pre-migration fallback to the legacy local-app-account_code key. There is no bespoke transient layer — WordPress’s own options cache handles repeated reads within a request. set() writes the canonical key; delete() clears both the canonical and legacy keys so no stale value can resurface through the alias filter.


Enrollment-server verification

Verification lives on the publish page, not in this manager: mam_app_submit::verify_account_code() (includes/publish-app/app-submit.php) compares the local value against what WPMAM has on file and surfaces a mismatch warning. A drift means contact support — the page does not auto-correct.


What references the account code

Surface Use
Publish page verify_account_code() before submit
Push credentials Some credential paths key by account code on WPMAM’s side
Plugin entitlement mam_plugin_entitlement filter (in plugin-update-manager) keys by account code
Setup wizard Tracks installation progress per account
Mobile JSON Some sibling plugins include the account code in the payload for analytics keying (via mam_multi_app_get_account_code filter)

Option Owner Purpose
local-app-account_code MAM_Account_Code_Manager Customer enrollment ID — frozen contract
local-app-onboarding-status setup-wizard Wizard progress — frozen contract
local-app-activated-plugin plugin-update-manager Activated-plugin tracking
mam_gravity_forms_deactivated setup-wizard GF deactivation marker

Hooks

Hook Type Purpose
mam_multi_app_get_account_code Filter Multi-app sites can override which account code applies to which app
mam_plugin_entitlement Filter Per-plugin licensing check — keys by account code

Frozen contract callout

local-app-account_code is frozen — do not rename. Concretely:

  • ~2K customer sites have a value persisted today
  • Customer mobile apps reference it
  • The publish pipeline depends on its presence
  • Renaming requires coordinated migration of every site, every mobile build, and the WPMAM enrollment server

Encryption-at-rest is a tracked hardening task. Today the option is plaintext.


Gotchas

  • Write only through MAM_Account_Code_Manager::set(). Direct update_option('local-app-account_code', ...) writes the legacy key only and skips the canonical mam-account-code key the manager reads first.
  • Don’t auto-correct mismatches. A drift between local and WPMAM means contact support — auto-correcting risks rerouting publishes to the wrong customer’s App Store account.
  • delete() clears both keys. It removes the canonical and legacy options together so a stale legacy value can’t resurface through the alias filter.
  • Plaintext storage. Tracked hardening item.

  • Recipe: Customer enrollment and account code
  • Recipe: Publish your app to iOS and Android
  • Hook: mam_plugin_entitlement
  • Frozen public contracts reference

Metadata

Field Value
Article type Plugin Overview
Plugin slug mam-main
Applies to plugin version 2.1.11+
Category Plugin Reference
Audience PHP developer
Last verified 2026-05-02
Was this article helpful?
Contents

    Need Support?

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