Need javascript help: call the modal login window after page load

Posted in: Newspaper
Post count: 64

Hi everyone,

I’m trying to automatically call up the login window after a page loads.

The trigger is easy, when an url has a token like mydomain.com/?doaction=show-login-window, a javascript is printed in the page to call the login window function, or to simulate a click in the login link that has the #login-form anchor. This part I got it working.

I just can’t produce a javascript to call the window, I tried .click() and toggle() but I’m very bad at javascript.

Any help is very much appreciated, thanks! Cheers

PS: the reason to want this is because I have the website available in http and https (also force_ssl_admin) and I want to use the beautiful modal login window. Due to this (miss)configuration, the modal login window should only be available when connecting with https. When connecting with http the modal window link is currently being replaced with a link to regular old wp-login.php but I think it would be nice if I could redirect a user to the https version and call the login window automatically.

  • This topic was modified 10 years by nf_prt.
Post count: 1291

Hi,

We use magnificpopup for the modal, try the following solution: – http://screencast.com/t/aHl2ObwO6yEo
Add the code in the footer.php after wp_footer().

<?php if(!is_user_logged_in()) { ?>
<script>
    jQuery().ready(function() {
        'use strict';

        jQuery('.td-login-modal-js').magnificPopup('open');
        });
</script>
<?php } ?>

It will appear only when the user is not logged in. You could add more condition in the php conditional if you want.

Thank you!

  • This reply was modified 10 years by Emil G.
Post count: 64

Hi Emil,

thank you so much, it works like a charm! I did add more conditions because I wanted to only run on call.

Cheers!

Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic.