Magic Login
Passwords are a hassle. Users forget them, reuse them, and create weak ones. Magic Login lets users sign in with just their email address — they receive a secure link or code, click or enter it, and they’re in. No password required.
Use Cases
- Simplify login for users who forget passwords
- Provide quick access links in transactional emails
- Offer code-based login for mobile users
- Enable QR code scanning for fast mobile authentication
How It Works
Link-Based Login
- User enters their email on the login form
- They receive an email with a secure, one-time link
- Clicking the link logs them in immediately
- Link expires after configured time (default: 15 minutes)
Code-Based Login
- User enters their email on the login form
- They receive an email with a 6-digit code
- They enter the code on the verification screen
- Correct code logs them in
QR Code Login
- User requests a magic link email
- Email includes a scannable QR code
- Scanning on mobile opens the link directly
- User is logged in on their mobile device
Settings
| Setting | Type | Default | Description |
|---|---|---|---|
| Link Expiry | Number | 15 | Minutes until magic links expire |
| Allow Code Login | Toggle | On | Let users choose to receive codes instead |
| Include QR Code | Toggle | On | Add QR code to magic link emails |
| Redirect After Login | URL | — | Where to send users after login (blank = admin) |
| Email Subject | Text | — | Custom email subject line |
| Email Content | Textarea | — | Custom email template with placeholders |
Email Placeholders
Use these in custom email templates:
| Placeholder | Description |
|---|---|
{{MAGIC_LINK}} | The one-click login URL |
{{MAGIC_CODE}} | The 6-digit verification code |
{{USER_NAME}} | User’s display name |
{{SITE_NAME}} | Your site name |
{{EXPIRY}} | Link expiration time |
Auto-Login in Emails
The {{MAGIC_LINK}} placeholder works in any WordPress email, not just magic login emails. Use it to include one-click login links in:
- WooCommerce order confirmations
- Membership welcome emails
- Newsletter links
- Support ticket responses
Example in an email template:
Click here to view your order: {{MAGIC_LINK}}Shortcode
Add a magic login form anywhere with:
[magic_login]Optional attributes:
redirect— URL to redirect after loginlabel— Custom button label
Example:
[magic_login redirect="/my-account" label="Sign In"]Security Features
| Feature | Description |
|---|---|
| One-Time Use | Each link/code works only once |
| Time-Limited | Links expire after configured time |
| Encrypted Storage | Tokens encrypted with AES-256-GCM |
| Rate Limiting | Prevents abuse of login requests |
| IP Binding | Optional — bind links to requesting IP |
CAPTCHA Integration
Magic Login integrates with Switchboard CAPTCHA modules:
- Cloudflare Turnstile
- Google reCAPTCHA
- Simple CAPTCHA
Enable CAPTCHA protection in those modules and turn on “Protect Magic Login” to prevent abuse of the magic login form.
FAQ
Is magic login secure?
Yes. Links use cryptographically random tokens, expire quickly, and work only once. They’re as secure as password reset links — which every site already uses.What if someone intercepts the email?
The same risk exists for password reset emails. Magic links are one-time use and expire quickly, limiting the attack window. Use HTTPS and consider IP binding for additional security.Can users still use passwords?
Yes. Magic login is an alternative, not a replacement. The normal WordPress login form still works for password-based login.Does this work with two-factor authentication?
Magic login bypasses password entry, so traditional 2FA that triggers after password entry won’t apply. The magic link itself serves as the authentication factor.Can I disable password login entirely?
This module doesn’t remove password login. It adds an alternative. For password-less only, you’d need additional customization.Magic login works great for membership sites where you want to reduce login friction. Include {{MAGIC_LINK}} in welcome emails so new members can access their account instantly.
Get access to all 166 modules with a single license