Magic for WordPress

Magic for WordPress

Login by Magic is a WordPress Plugin that integrates your WordPress sites with your Magic account. This plugin replaces the standard WordPress login form with one that is powered by Magic. The Magic login form enables passwordless login with email magic link.

The Login by Magic plugin handles login and account creation flows automatically by creating or matching user accounts with the email provided. In the login process, an account will be created or matched based on the data in your WordPress database.

This plugin is for WordPress websites that have existing users and want to switch from a username and password login to Magic’s passwordless login. Existing users must have a valid email associated with their account. New users will be associated with the email that they use to log in.

Install Login by Magic

note

To install or customize plugins, you must use a self-hosted WordPress.org site. Using a WordPress.com site does not allow installing plugins, unless you're on Business or eCommerce plan. To learn more about the differences, click here.

This plugin can be added to your WordPress site using the Plugins screen in the wp-admin:

  1. Log in to an existing WordPress site as an administrator.
  2. Go to Plugins > Add New in the admin menu on the left hand side.
  3. Search for “Login by Magic” or “magiclabs”
  4. When you find the Login by Magic plugin, click Install Now and then Activate.

Once the plugin is activated, it’s time to configure the plugin.

If you don't already have a Magic account, sign up for a free account before proceeding.

Configure Login by Magic

A user can configure Login by Magic manually by visiting the Settings > Login by Magic page.

Magic configuration

Your Magic account must have an application for your WordPress site. If you don’t have one yet, create one.

  1. Create or select an Application from the dashboard.
  2. Select the Home view for the Application. You will see your PUBLISHABLE API KEY and SECRET KEY, which are used in wp-admin > Settings > Login by Magic to connect your WordPress site with your Magic account. Magic Dashboard

WordPress configuration

  1. Go to the Magic Dashboard, select the Application you just created. Keep this tab open. We will use the keys from this page.
  2. In a new tab, log in to wp-admin for your WordPress site and go to wp-admin > Settings > Login by Magic.
  3. Complete the WordPress settings using your Magic application’s PUBLISHABLE API KEY and SECRET KEY.
  4. Redirect URI is an optional field. Putting the slug of a page, such as /my-account will redirect the user to this page after a successful authentication. Leaving it blank will redirect the user back to the root of your website.
  5. Select User role from the dropdown menu.
  • Administrator
  • Editor
  • Author
  • Contributor
  • Subscriber To read more about roles and capabilities, click here.
  1. Select the Admin login check box to replace the admin login form powered by Magic.
  2. Click on Save Changes to complete the configuration. Login by Magic WordPress Plugin - WordPress options

WooCommerce configuration

  1. Follow Step 1-3 from the WordPress Configuration.
  2. Redirect URI is an optional field. By putting the slug of a page, such as /my-account will redirect the user to the /my-account page after successful authentication. Avoid leaving this field blank for WooCommerce websites to provide a better experience for your users.
  3. Two additional roles will appear for WooCommerce sites.
  • Customer
  • Shop manager
  1. Select the Admin login check box to replace the admin login form with one that is powered by Magic.
  2. Similarly, select the WooCommerce login check box to replace the WooCommerce login form with one that is powered by Magic.
  3. Click on Save Changes to complete the configuration. Login by Magic WordPress Plugin - WooCommerce options

How the Plugin Works

  1. The user accesses the WordPress site’s login page. It could be the main login page at [SITE URL]/wp-login.php or a page containing a widget or shortcode.
  2. The user provides their email address, clicks on the Send button.
  3. A pop-up modal with the following message appears: Check your email
  4. The user will check the email they received from Magic.
  5. They click on the Log in to {Application Name} button
  6. Once they’ve clicked on the magic link email, they’ll be successfully logged in and redirected either to the homepage or the Redirected URI.
note

By this time the user is considered a logged in user in both the original and new tabs. They will also have the role you’ve selected at the WordPress configuration step.

Troubleshoot

F.A.Q.

My local WordPress installation is showing an error and I am unable to login.

To use this plugin, please use a live WordPress installation that has an SSL certificate installed on it. Using an HTTP version of your WordPress installation is not recommended and will show App error.

I’m seeing the error message “App error, Invalid scheme detected.”

Please make sure the input scheme is one of [https]. Install SSL certificate to your server.