Skip to content

Plugin: Auto Login Placeholder

This plugin adds the %autologinlink% placeholder to aMember email templates. When an email is sent, the placeholder is replaced with a unique link such as:

https://example.com/amember/l/A43803CY4569

Opening the link logs the recipient in to aMember automatically. The link remains valid for the lifetime configured in the plugin and is invalidated when the user changes their password.

Section titled “Generate an auto-login link with the REST API”

The plugin adds the GET /api/autologinlink endpoint. Before using it:

  1. Enable the REST API module.
  2. Go to aMember CP > Configuration > Remote API Permissions and create or edit an API key.
  3. Grant the API key index permission for the autologinlink controller.

See REST API authorization and API key setup for general REST API configuration.

Identify the user with one of these query parameters:

ParameterDescription
user_idaMember user ID
loginaMember username
emailUser's email address

Send only one user identifier per request. For example, the following request finds a user by email address and supplies the API key in the X-API-Key header:

Terminal window
curl --get 'https://example.com/amember/api/autologinlink' \
--header 'X-API-Key: APIKEY' \
--data-urlencode 'email=member@example.com'

A successful request returns the generated link:

{
"ok": true,
"autologinlink": "https://example.com/amember/l/A43803CY4569"
}

If no user matches the supplied identifier, the response is:

{
"ok": false,
"msg": "Unable to find user"
}

You can supply the API key in the _key query parameter instead, but using the header prevents the key from appearing in URLs and access logs. Use HTTPS and treat both the API key and generated links as secrets. Anyone with a valid auto-login link can sign in as that user until the link expires.