• Resolved ogia

    (@ogia)


    I have installed Magic Login and it’s working to log users into WordPress as expected. Is it possible for the magic link to log users in by their email address instead of their WP username? I’m trying to coordinate with my membership system (DAP) and it syncs WP users by email address, so if they log into WP with username, they aren’t getting logged in as a member.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Author Mustafa Uysal

    (@m_uysl)

    Hi @ogia,

    Thank you for using Magic Login!

    Yes, it’s possible to log users in by their email address instead of their WP username. Magic Login supports both email addresses and usernames for logging in.

    and it syncs WP users by email address, so if they log into WP with username, they aren’t getting logged in as a member.

    This seems a bit weird to me, as the WordPress authentication cookie shouldn’t be affected by whether users log in with their username or email address. The same cookie should be used for authentication regardless of the method.

    Thread Starter ogia

    (@ogia)

    Thanks for the quick response. Where is the option to ensure they’re being logged in by email address? I’m not sure exactly how DAP works, but it says in the docs as long as they are logged in by email address into WP, it will sync with DAP. DAP has a separate log in system.

    • This reply was modified 2 months, 3 weeks ago by ogia.
    Plugin Author Mustafa Uysal

    (@m_uysl)

    Where is the option to ensure they’re being logged in by email address?

    We don’t have an option for that, since the plugin is designed to accept both. But you can add frontend enforcement for the form that acceps to email address only with this snippet (assuming you are using shortcode to add magic login form?)

    function enqueue_magic_login_email_only_script() {
    	?>
        <script type="text/javascript">
    		document.addEventListener("DOMContentLoaded", function() {
    			// Find the form by ID
    			var form = document.getElementById("magicloginform");
    
    			if (form) {
    				// Find the input field by name within the form
    				var userLoginInput = form.querySelector("input[name='log']");
    
    				if (userLoginInput) {
    					// Force the input field to accept only email addresses
    					userLoginInput.setAttribute("type", "email");
    					userLoginInput.setAttribute("placeholder", "Enter your email address");
    				}
    			}
    		});
        </script>
    	<?php
    }
    
    add_action('wp_footer', 'enqueue_magic_login_email_only_script');

    And you will probably want to update info message like this:

    
    [magic_login_form info_message="Please enter your email address. You will receive an email message to log in."]
    

    (you can learn more about supported shortcode parameters here: https://handyplugins.co/docs/magic-login-shortcode/)

    I’m not sure exactly how DAP works, but it says in the docs as long as they are logged in by email address into WP, it will sync with DAP. DAP has a separate log in system.

    This makes more sense now ?? However, I was expecting that they wouldn’t alter the login behavior, especially since they can already retrieve email addresses using the username as well.

    • This reply was modified 2 months, 3 weeks ago by Mustafa Uysal. Reason: added example shortcode with info message
    • This reply was modified 2 months, 3 weeks ago by Mustafa Uysal.
    Thread Starter ogia

    (@ogia)

    Thanks for that code, however, I am already testing the form by entering the email address. Maybe the way the magic login link logs users into WP is not compatible with DAP.

    Plugin Author Mustafa Uysal

    (@m_uysl)

    It’s always possible to have conflicts with third-party plugins. Magic Login sets the authentication process ‘almost’ identical to the standard method used when logging into WordPress.

    Is there any public documentation about DAP? (I’m not sure what that is or how does it work.)

    Plugin Author Mustafa Uysal

    (@m_uysl)

    Alright, I’ve read through some posts and now understand what DAP is. Unfortunately, Magic Login doesn’t support DAP and doesn’t intend to in the future.

    If you are newly starting your membership site, I strongly recommend a proper membership plugin that actually works with WordPress.

    Feel free to ping me via support[at]handyplugins.co if you want to hear more details about DAP from me. (Public WordPress forums are not the best place to share such ideas on commercial products)

Viewing 6 replies - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.