WordPress.org

Ready to get started?Download WordPress

Forums

SimpleModal Login
Pop login from javascript (7 posts)

  1. gypsie
    Member
    Posted 3 years ago #

    Hi,

    First, thanks for writing the plugin. Best ajax login out there. It's is nice and clean code. Saved me a lot of time. Everything is working fine for me except I got decision tree in javascript and I need to pop the login window from javascript. All your documentation focuses on how to include an href link in the html code that will pop the login/registartion window or how to embed php function call. That is very clear to me. However I do not see any documentation on how to pop the login window using javascript function call (without clicking on link). Is there something that would would allow me to do something like the following:

    if(this_condition == true){
    pop_the_login_window();
    }

    thanks for any help

    http://wordpress.org/extend/plugins/simplemodal-login/

  2. Eric Martin
    Member
    Plugin Author

    Posted 3 years ago #

    Because SimpleModal Login binds the click event to the simplemodal-login class, with jQuery you can trigger the event with:

    jQuery('.simplemodal-login').trigger('click.simplemodal-login');

    Hope that helps.

    -Eric

  3. gypsie
    Member
    Posted 3 years ago #

    Thanks!

  4. gypsie
    Member
    Posted 3 years ago #


  5. gypsie
    Member
    Posted 3 years ago #

    Hmm, I celebrated too soon. One issue that arose now is that redirection is taking user after login to wordpress administration backend. That is undesired behavior. When using php function call I can provide the parameter where to go after login:

    wp_loginout($_SERVER['REQUEST_URI']);

    but with jquery call I can't provide the redirect parameter. When I place alert() call in the default.js after the:

    s.url = this.href;
    alert(s.url);

    it pops 3 times with following paths:

    http://new.domain.com/login/?redirect_to=%2F
    http://new.domain.com/login/
    http://new.domain.com/login/

    It seems my jquery call parameters are overridden by 2 subsequent additional calls and "http://new.domain.com/login/?redirect_to=%2F" path is lost. When I use just the regular href login link, alert() pops only 1 time showing correct redirect link:

    http://new.domain.com/login/?redirect_to=%2F

    Any idea what other 2 calls is jQuery('.simplemodal-login').trigger('click.simplemodal-login') triggering and how to prevent it? Or alternatively, is there a way to provide a redirect parameter to jquery to ensure correct redirection after the form is submitted?

  6. gypsie
    Member
    Posted 3 years ago #

    This is what I ended up doing.

    var ref = jQuery("input[name='_wp_original_http_referer']").val();
    jQuery('#loginform').append(jQuery('<input type="hidden" name="redirect_to">').val(unescape(ref)));
    jQuery('.simplemodal-login').trigger('click.simplemodal-login');

    not sure if it is the most elegant way to do it but it works.

  7. dk-andersson
    Member
    Posted 3 years ago #

    Help me!!!!

    I have tride your script

    jQuery('.simplemodal-login').trigger('click.simplemodal-login');

    This is not working for me why??? Do I need to put som more kode in to
    trigger click onload??

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic