See it on: GitHub
First, install the plugin: https://wordpress.com/support/plugins/install-a-plugin/
Before using the Magic Login Plugin, you need to configure the following constants in your wp-config.php
file.
Visit www.magic.mk, log in and make a project, then:
MAGIC_LOGIN_API_KEY
: Your MagicMK project API key.MAGIC_LOGIN_PROJECT_KEY
: Your MagicMK project key.Add these lines to your wp-config.php
:
define('MAGIC_LOGIN_API_KEY', 'your_api_key_here');
define('MAGIC_LOGIN_PROJECT_KEY', 'your_project_key_here');
Optional: If you need to override the default Magic Login URL (e.g., for local testing), you can add:
define('MAGIC_URL_OVERWRITE', 'https://your-custom-magic-url.com');
When overwriting, please keep this structure and build upon it:
<form id="magic-form">
<input id="magic-input" required>
<button id="magic-submit"></button>
<div id="RecaptchaField"></div>
<p id="validation-message"></p>
</form>
<script>
window.magicmk = {
project_slug: '<?php echo esc_js(get_query_var('magic_login_project_key')); ?>',
language: '',
redirect_url: '',
params: {
extra: "parameters",
}
};
</script>
<script src="<?php echo esc_url(get_query_var('magic_url')); ?>/magicmk_integration_min.js"></script>
You can override the default template by creating a custom template file in your theme. There are two ways to do this:
magic-login-plugin
in your theme directory.magic-login-template.php
.templates/magic-login-template.php
into your new file.File path: wp-content/themes/your-theme/magic-login-plugin/magic-login-template.php
magic-login-template.php
.templates/magic-login-template.php
into your new file.File path: wp-content/themes/your-theme/magic-login-template.php
Note: The plugin will prioritize Option A over Option B if both exist.
The Magic Login Plugin provides several filters and actions to customize the login page without overriding the entire template.
magic_login_page_title
: Modify the page title.
add_filter('magic_login_page_title', function($title) {
return 'Custom Magic Login';
});
magic_login_form_class
: Add custom classes to the login form.
add_filter('magic_login_form_class', function($classes) {
return $classes . ' my-custom-class';
});
magic_login_head
: Add custom content to the <head>
section.
add_action('magic_login_head', function() {
echo '<style>.magic-login-form { background: #f1f1f1; }</style>';
});
magic_login_before_form
: Add content before the login form.
add_action('magic_login_before_form', function() {
echo '<h2>Welcome to Magic Login</h2>';
});
magic_login_before_fields
: Add content inside the form, before the default fields.
add_action('magic_login_before_fields', function() {
echo '<div class="custom-message">Enter your details below:</div>';
});
magic_login_after_fields
: Add content inside the form, after the default fields.
add_action('magic_login_after_fields', function() {
echo '<div class="terms-agreement">By logging in, you agree to our terms.</div>';
});
magic_login_after_form
: Add content after the login form.
add_action('magic_login_after_form', function() {
echo '<div class="post-form-content">Need help? Contact support.</div>';
});
magic_login_footer
: Add custom content just before the closing </body>
tag.
add_action('magic_login_footer', function() {
echo '<script>console.log("Magic Login loaded");</script>';
});