Integrations & Developers
How Can I Manage Magic Link Using WordPress CLI?
Quick Answer
Magic Link ships with a WP-CLI command so you can generate login links from the command line. The base command is free; the --redirect-to flag is PRO.
The Command
wp magic-link generate <user>
<user> accepts any of:
- a user ID —
42 - an email —
alex@company.com - a login (username) —
alex
Flags
--count=<N>— generate N links at once (default is 1).--send— email the link to the user instead of only printing it.--redirect-to=<url>— set where the user lands after logging in (PRO).
Examples
Generate a single link for a user by email:
wp magic-link generate alex@company.com
Generate a link by user ID and email it to them:
wp magic-link generate 42 --send
Generate three links for a username:
wp magic-link generate alex --count=3
Generate a link that redirects to a specific page after login (PRO):
wp magic-link generate alex@company.com --redirect-to=https://example.com/account
Why Use It
- Developers and administrators can create links without opening the dashboard.
- Fits automated workflows and scripts.