Pop Up A Window When Logged In Successfully…

I have a client who needs a pop-up-window with the url of his chat to load once and only once during the login. I thought this would be easy and it seems to be having problems. Maybe somebody can help?

function popupchat() {

?>

<SCRIPT LANGUAGE="javascript">

<!--

window.open ('http://languageconnectsus.gixawchat.com/')

-->

</SCRIPT>

<?php

}

add_action('wp_login ', 'popupchat');

Added that as a file in mu-plugins and it doesn’t work. Any suggestions?

  • Andrew
    • Champion of Loops

    Hmm, the redirect is probably taking place before the JS is executed. I’m not sure there’s much you can do about that since it’s JS.

    You may need to set some kind of flag on login and have the JS executed on the page the user is redirected to.

    If you want to go that route you could use the wp_redirect filter to add on a flag to the redirect url if the user is being redirected from wp-login.php. Something like:

    http://redirect.to.tld/whatever/#do-popup

    You could then have a function running via the wp_footer and admin_footer hooks that looks for the flag and echoes the JS if the flag is found.

    Thanks,

    Andrew

  • Andrew
    • Champion of Loops

    Hiya,

    I’m afraid I don’t have time to look for simpler ways. I was just suggesting one way that would work.

    As for my solution described above. It’s really not super complex code-wise. You’re just tagging on something to the end of the redirect url via the wp_redirect filter and then using the admin_footer and wp_footer (same function for both) hooks to execute the JS if the ‘flag’ is in the url.

    snippets that may help:


    if (stristr($_SERVER, ‘wp-login.php’:wink:){

    }


    if (stristr($_SERVER, ‘do-popup’:wink:){

    }


    add_action(‘admin_footer’, ‘do_popup’:wink:;

    add_action(‘wp_footer’, ‘do_popup’:wink:;

    function do_popup() {

    }


    add_filter(‘wp_redirect’, ‘popup_redirect_filter’, 2);

    function popup_redirect_filter ($location, $status){

    return $locaction . ‘#do-popup’;

    {


    Again though, there’s probably a simpler way. If the above doesn’t help hopefully someone else will pop in with a suggestion or two.

    Thanks,

    Andrew

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.