Skip to content
  1. Extras
  2. HybridAuth
  3. Snippets
  4. HybridAuth

HybridAuth

Snippet outputs a sign-in form for the site.

Parameters

NameDefaultDescription
&activeProviderTpltpl.HybridAuth.provider.activeChunk for the icon of the linked provider.
&addContextsAdditional contexts, comma-separated. E.g. &addContexts=`web,ru,en`
&groupsList of groups for user registration, comma-separated. You can specify user role in the group with a colon. E.g. &groups=`Users:1` adds the user to group "Users" with role "member".
&loginContextcurrent contextMain context for authentication. Default is current.
&loginResourceId0Resource ID to redirect the user to after login. Default 0 refreshes the current page.
&loginTpltpl.HybridAuth.loginThis chunk is shown to anonymous users (guests).
&logoutResourceId0Resource ID to redirect the user to after logout. Default 0 refreshes the current page.
&logoutTpltpl.HybridAuth.logoutThis chunk is shown to authenticated users.
&providerTpltpl.HybridAuth.providerChunk for the sign-in or link-provider link.
&providersall availableList of auth providers, comma-separated. All available providers are in {core_path}components/hybridauth/model/hybridauth/lib/Providers/. E.g. ```&providers=`Google,Twitter,Facebook````.
&rememberme1Remember the user for a long time. Default is on.

Examples

Call the snippet uncached, because it outputs different chunks depending on authentication.

With a normal call the snippet shows all providers registered in the system:

modx
[[!HybridAuth]]

You can limit them with a comma-separated list:

modx
[[!HybridAuth?
  &providers=`Yandex,Google,Twitter,Facebook,Vkontakte`
]]

Sign in to 2 contexts at once:

modx
[[!HybridAuth?
  &providers=`Yandex,Google`
  &loginContext=`web`
  &addContexts=`en`
]]

Provider settings

Each auth provider has its own system setting with the ha.keys. prefix:

Provider settings

The setting value is a JSON array; its contents depend on the provider.

For example, Google needs id and secret, while Twitter needs key and secret. Check what the provider gives you when you register.

You need to obtain keys from the provider. Main links:

Contexts

If you have several independent contexts, you can use the same providers for different domains.

Put the keys in the context settings, not in global system settings.

Friendly URLs are recommended for the snippet to work correctly.