Gatey Reference

Dynamic shortcodes, CSS variables & a secure JS API for authentication-aware UI

Gatey Front‑End Reference

Welcome to the complete Gatey front-end reference manual—your one-stop list of every shortcode, dynamic CSS variable, JavaScript helper, DOM event, and Redux field.

1. WordPress Shortcodes

gatey

Embeds a Cognito‑powered <Authenticator> wherever you like—inside a post, a popup, or an Elementor template.

AttributeAccepted valuesExplanation
id (required)Gutenberg pattern IDTells Gatey which saved Gutenberg pattern—containing an <Authenticator> block—to render. Not meant for DOM‑event targeting; if you need a hook for JavaScript listeners, give the rendered element a normal CSS id.
screensignIn, signUp, editAccount, setupTotp, forgotPassword, changePasswordInitial Authenticator screen.
variationdefault, modalInline widget or modal overlay.
colormodelight, dark, systemForce colour scheme or follow OS preference.
languagear – Arabic,
de – German,
en – English (default),
es – Spanish,
fr – French,
he – Hebrew,
hi – Hindi,
id – Indonesian,
it – Italian,
ja – Japanese,
ko – Korean,
kr – Korean (legacy),
nb – Norwegian Bokmål,
nl – Dutch,
pl – Polish,
pt – Portuguese,
ru – Russian,
sv – Swedish,
th – Thai,
tr – Turkish,
ua – Ukrainian,
zh – Chinese
Sets the UI language. Specify any of the codes above to lock the interface locale, or omit the attribute to let the
browser/OS preference decide automatically.
directionauto – Auto (default),
ltr – Left-to-Right,
rtl – Right-to-Left
Sets overall text flow.
showopentrue, falseIf true, renders a button first; clicking it opens the Authenticator with the configured screen. Defaults to false.
openFree‑text stringReplaces the default label on the open button (defaults to the Authenticator header) when showopen is enabled.
signinginFree‑text stringMessage displayed while the Authenticator is in the signing‑in state (fires with signing-in.gatey-authenticator). Empty by default.
signingoutFree‑text stringMessage displayed while signing out (fires with signing-out.gatey-authenticator). Empty by default.
redirectingFree‑text stringMessage shown during the post-login or post-logout redirect if a redirect URL is configured (fires with signed-in.gatey-authenticator and signed-out.gatey-authenticator). Empty by default.

gatey-account

Outputs a Cognito user‑attribute in place—perfect for personalised greetings, user dashboards, or conditional content.

AttributeAccepted valuesExplanation
componentdiv, p, span, h1, h2, h3, h4, h5, h6The HTML tag Gatey should render for the output.
Use a heading, block or inline element to match your layout.
Defaults to div if omitted.
attributeAny standard Cognito field (e.g. email, given_name)
Literal custom for non‑standard.
The profile field you want to print.
customName without the custom: prefixRequired only when attribute="custom".

Usage examples

gatey id="12" variation="modal" colormode="dark"

Welcome back, gatey-account attribute="given_name"!

Your tier: gatey-account attribute="custom" custom="membershipTier"]

2. Dynamic CSS Custom Properties

Gatey injects these variables on :root. Use them to toggle visibility (flex/none) or print Cognito data via content.

Initialisation flags

  • --gatey-initialized / --gatey-not-initialized

Editor mode

When a page is open in Elementor or Gutenberg, Gatey sets --gatey-in-editor to flex so those elements remain visible inside the editor even if they would be hidden on the live site—making them easier to edit:

body.elementor-editor-active,
body.wp-admin,
body.block-editor-iframe__body {
  --gatey-in-editor: flex;
}

Authentication & MFA

  • --gatey-account-authenticated / --gatey-account-not-authenticated
  • --gatey-account-mfa-enabled / --gatey-account-mfa-not-enabled

Group membership

For every Cognito group <g> Gatey outputs:

  • --gatey-account-group-<g>
  • --gatey-account-group-not-<g>

Cognito attributes

  • --gatey-account-attribute-email
  • --gatey-account-attribute-family_name
  • Customs: --gatey-account-attribute-custom-<attr>
/* Visible only to admins */
.admin-panel{
  display:var(--gatey-account-group-admin);
}

/* Show element while editing */
.show-in-editor-or-if-authenticated{
  display:var(--gatey-in-editor, var(--gatey-account-authenticated, none));
}

3. JavaScript API (Gatey.cognito.*)

All helper methods live on the global Gatey.cognito object (available after the DOM finishes loading); each one returns a Promise, so use await or .then().

HelperReturnsUse case
getUsername()stringDisplay the username
getUserAttributes()objectPrefill a form with profile data
getMfaPreferences()objectShow MFA status
clearMfaPreferences()voidOne-click TOTP disable
isAuthenticated()booleanGuard a route or action
isInGroup("admin")booleanRole-based UI
getGroups()string[]Render a badge list
getRoles()string[]IAM role switcher
getScopes()string[]Scope-aware buttons
getPreferredRole()stringAuto-select a role
setLanguage("en")voidSwitch the Authenticator’s UI language at runtime
setDirection("ltr")voidOverride the layout direction (auto, ltr or rtl)
signOut()voidCustom logout button
getAmplifyConfigobjectDebug current Amplify settings
get / post / …anySigned API calls through aws-amplify/api
// Sample signed API call
const orders = await Gatey.cognito.post({
  apiName: "backend",
  path: "/orders",
  options: { body: { status: "OPEN" } }
});
console.table(orders);

In the Gutenberg editor, any “Custom Block” element inside the Authenticator block—such as an <a> tag or <button>—can use the onclick attribute with toSignIn(), toSignUp(), or toForgotPassword() to switch directly to the Sign In, Sign Up, or Forgot Password screens.

4. DOM Events from <Authenticator>

Every event is emitted under the name pattern
<type>.gatey-authenticator—for example
done.gatey-authenticator or
cancel.gatey-authenticator.
Give your <Authenticator> (or shortcode)
an id, then attach a listener with
addEventListener.

Event type
(before .gatey-authenticator)
When it fires
doneScreen finished (e.g. password changed)
cancelUser pressed Cancel / Back
signing-inCognito login done, WP login still running
signed-inAll hooks finished → redirect
signing-outHooks + WP logout executing
signed-outFully signed out → redirect
resetAuthenticator re-appears (e.g. code prompt)
// Example listener
const authEl = document.getElementById("login-widget");
authEl.addEventListener("done.gatey-authenticator", () => {
  toast.success("Profile updated!");
});

5. observeStore() – Watch Redux State

The Redux store is exposed asynchronously as Gatey.cognito.store
(a Promise). When it resolves, pass the store to
Gatey.cognito.observeStore along with a selector and a
callback:

// Reload the page if the visitor signs out
Gatey.cognito.store.then((store) =>
  Gatey.cognito.observeStore(
    store,
    (state) => state.signedIn,
    (signedIn, prev) => {
      if (prev !== undefined && !signedIn) {
        window.location.reload();
      }
    }
  )
);

Common selectors:

  • state.amplifyConfigResourcesConfig returned by Amplify
  • state.signedIntrue | false
  • state.account — object containing:
    • username
    • userAttributes
    • mfaPreferences