Title: [Plugin: SimpleModal Login] Pop login from javascript
Last modified: August 19, 2016

---

# [Plugin: SimpleModal Login] Pop login from javascript

 *  [Commercial Networks](https://wordpress.org/support/users/gypsie/)
 * (@gypsie)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-simplemodal-login-pop-login-from-javascript/)
 * 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/](http://wordpress.org/extend/plugins/simplemodal-login/)

Viewing 6 replies - 1 through 6 (of 6 total)

 *  Plugin Author [Eric](https://wordpress.org/support/users/emartin24/)
 * (@emartin24)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-simplemodal-login-pop-login-from-javascript/#post-1697351)
 * 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
 *  Thread Starter [Commercial Networks](https://wordpress.org/support/users/gypsie/)
 * (@gypsie)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-simplemodal-login-pop-login-from-javascript/#post-1697520)
 * Thanks!
 *  Thread Starter [Commercial Networks](https://wordpress.org/support/users/gypsie/)
 * (@gypsie)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-simplemodal-login-pop-login-from-javascript/#post-1697521)
 *  Thread Starter [Commercial Networks](https://wordpress.org/support/users/gypsie/)
 * (@gypsie)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-simplemodal-login-pop-login-from-javascript/#post-1697524)
 * 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&#8221](http://new.domain.com/login/?redirect_to=%2F&#8221);
   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?
 *  Thread Starter [Commercial Networks](https://wordpress.org/support/users/gypsie/)
 * (@gypsie)
 * [15 years, 8 months ago](https://wordpress.org/support/topic/plugin-simplemodal-login-pop-login-from-javascript/#post-1697525)
 * 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.
 *  [dk-andersson](https://wordpress.org/support/users/dk-andersson/)
 * (@dk-andersson)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-simplemodal-login-pop-login-from-javascript/#post-1697658)
 * 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??

Viewing 6 replies - 1 through 6 (of 6 total)

The topic ‘[Plugin: SimpleModal Login] Pop login from javascript’ is closed to new
replies.

 * ![](https://s.w.org/plugins/geopattern-icon/simplemodal-login.svg)
 * [SimpleModal Login](https://wordpress.org/plugins/simplemodal-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simplemodal-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simplemodal-login/)
 * [Active Topics](https://wordpress.org/support/plugin/simplemodal-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simplemodal-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simplemodal-login/reviews/)

 * 6 replies
 * 3 participants
 * Last reply from: [dk-andersson](https://wordpress.org/support/users/dk-andersson/)
 * Last activity: [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-simplemodal-login-pop-login-from-javascript/#post-1697658)
 * Status: not resolved