It’s easy to use the login from anywhere on your website by simply adding the
[magic_login_form]
shortcode. Most of the time it doesn’t require any additional effort to make it nice, but you can still customize it through custom CSS.
Customizations
In version 2.1, we have introduced support for additional attributes to enhance the flexibility of Magic Login.
Here are the list of supported attributes:
‘redirect_to‘ : The target redirection URL, it uses the page where the shortcode is added by default. (If you enforce redirection rules from settings, it will be overridden)
‘hide_logged_in‘: Whether show or not show magic login form on logged-in users.
‘error_message‘: Error message when user is not exists.
‘info_message‘: Standard informing message show on the form by default.
‘success_message‘: The message is displayed after the login email has been sent successfully.
‘label‘: The input label.
‘button_text‘: The text on the button.
‘class‘: You can add additional HTML classes to form with this.
- Form target URL can be controlled with magic_login_shortcode_form_action hook
- Specific redirected address with redirect_to attribute in shortcode
Use it in custom Template
<?php echo do_shortcode( '[magic_login_form redirect_to=""]' ); ?>
Display for logged-in users
By default, the shortcode does not produce any output if the user is logged in. This makes it convenient to use on pages intended for logged-in users, like “my-account” pages. However, this default behavior can be altered using the hide_logged_in attribute. Setting hide_logged_in=”false” allows the shortcode to be displayed regardless of the user’s login status.
[magic_login_form hide_logged_in="false"]