Site icon Hip-Hop Website Design and Development

Firing a function AFTER redirect

I am using a function that redirects the user to a custom page, rather than wp-login in the event of errors. In my case I am using the Http Referer function to send the user back to the same page because I have the login form in a modal. How can I execute a function on the redirected page, so that the page automatically opens the modal?

This is the code for the redirect in the event of an error:

add_filter('login_redirect', '_catch_login_error', 10, 3);
function _catch_login_error($redir1, $redir2, $wperr_user) {
    $rurl = $_SERVER['HTTP_REFERER'];
    if(!is_wp_error($wperr_user) || !$wperr_user->get_error_code()) return $redir1;
        switch($wperr_user->get_error_code()) {
            case 'incorrect_password': 
            case 'empty_password': 
            case 'invalid_username': 
            default: wp_redirect($rurl); }
        return $redir1;
     }

This code courtesy of http://projectivemotion.com/2011/12/16/redirect-failed-login-attempt-wordpress/#comment-653

The function I want to execute after redirect is:

add_action('genesis_before_post', 'force_open_modal_1');
function force_open_modal_1() { ?>
    <script type="text/javascript">
    jQuery(document).ready(function($){
        $('#loginmodal').reveal();
    });
    </script>
<?php }

Is this possible?