Skip to content

Frontend Shortcodes and Blocks

Guard Dog includes frontend surfaces for classic themes, shortcode templates, block themes, and custom account dashboards. Use these when users should manage security settings without visiting the WordPress admin profile screen.

Available Surfaces

Feature Shortcode Dynamic block Best for
Login form [guard_dog_login_form] guard-dog/login-form Public login pages
Account security [guard_dog_account_security] guard-dog/account-security One account page with multiple security modules
2FA management [guard_dog_two_factor] guard-dog/two-factor-auth Standalone 2FA setup and recovery codes
Session management [guard_dog_sessions] guard-dog/sessions Active device review and remote logout
Passkey management [guard_dog_passkeys] guard-dog/passkeys Passkey registration, rename, and deletion
Passkey login [guard_dog_passkey_login] guard-dog/passkey-login Custom login forms that need passkey sign-in

The legacy [guard_dog_2fa] shortcode remains supported. For new templates, use [guard_dog_two_factor] for the 2FA-only surface or [guard_dog_account_security] for the composite account-security panel.

Login Form

Use the login form shortcode when Guard Dog should render the whole public login surface:

[guard_dog_login_form redirect_to="/dashboard/" show_passkey="true" show_social_login="true"]

The login form can include username/password login, CAPTCHA, passkey login, social login buttons, remember-me, and lost-password controls.

Attribute Default Purpose
style Saved Login Security default default, minimal, or compact.
redirect_to empty URL to send users to after successful login.
show_passkey Saved Login Security default Show the passkey button when passkeys are enabled.
show_social_login Saved Login Security default Show social login buttons when Social Login and providers are configured.
show_remember_me Saved Login Security default Show the remember-me checkbox.
show_lost_password Saved Login Security default Show the lost-password link.
max_width Saved Login Security default Optional width in pixels, from 280 to 960.

Default values can be configured in Guard Dog -> Login Security -> Login Form. Individual shortcodes and blocks can override those defaults.

Account Security

Use the composite account-security surface when one logged-in account page should include multiple modules:

[guard_dog_account_security show_2fa="true" show_passkeys="true" show_sessions="true"]
Attribute Default Purpose
style default default, minimal, or compact.
show_2fa true Render app 2FA, email 2FA, and recovery-code controls.
show_passkeys true Render passkey management when passkeys are enabled.
show_sessions false Render active-session management when session tracking is enabled.

Use show_2fa="false" when your template places 2FA separately but still wants passkeys or sessions in the same account area.

2FA Management

Use the 2FA-only primitive when a page should show only 2FA controls:

[guard_dog_two_factor style="default"]

This surface lets logged-in users manage app-based 2FA, email-based 2FA, and recovery codes according to the methods enabled for the site.

Email 2FA setup only appears when email 2FA is enabled and an email provider is configured. This prevents users from enabling a method that cannot send verification codes.

Passkey Management

Use the passkey management primitive on account pages:

[guard_dog_passkeys style="default"]

This surface lets logged-in users register, rename, and delete passkeys. It returns no output when passkeys are disabled globally.

Session Management

Use the sessions primitive when users should review and terminate active sessions from the frontend:

[guard_dog_sessions style="compact"]

This surface only renders when session tracking is enabled and the visitor is logged in.

Passkey Login Button

Use the passkey login primitive when another template owns the username/password fields but should still offer passkey sign-in:

[guard_dog_passkey_login username_selector="#user_login" redirect_to="/dashboard/"]
Attribute Default Purpose
username_selector #user_login CSS selector for the username or email field.
redirect_to empty URL to send the user to after successful passkey login.
show_icon true Show or hide the button icon.
wrapper_class guard-dog-passkey-login Wrapper classes for theme styling.
button_class button button-secondary guard-dog-passkey-login__button Button classes for theme styling.
status_class guard-dog-passkey-login__status Status message classes for theme styling.

The passkey login button only renders for logged-out visitors when passkeys are enabled.

Block-Based Themes

Each shortcode has a matching dynamic block. Add the block in the editor, configure its sidebar settings, and Guard Dog will render the live output on the frontend.

Dynamic blocks do not save sensitive markup into post content. They render through Guard Dog at request time, so global settings, enabled methods, and user state are respected.

Rendering Multiple Modules

Guard Dog frontend modules are instance-safe. They generate unique IDs and data hooks so block themes, account dashboards, and shortcode-heavy templates can render more than one module on the same page without duplicate DOM IDs.

If a custom PHP template renders shortcodes after wp_head, enqueue assets before the header prints:

if ( function_exists( 'guard_dog_enqueue_account_security_assets' ) ) {
    add_action( 'wp_enqueue_scripts', function() {
        guard_dog_enqueue_account_security_assets(
            array(
                'show_2fa'      => true,
                'show_passkeys' => true,
                'show_sessions' => true,
            )
        );
    } );
}

← Password Policy | Documentation Home | Custom Login Integration →