I have a custom form for logging in (in a modal window) that looks like this:

    <form name="loginform" id="loginform" action="<?php echo wp_login_url( get_permalink() ); ?>/wp-login.php" method="post">

        <p class="login-username">
            <label for="user_login">Username or Email Address</label>
            <input type="text" name="log" id="user_login" class="input" value="" size="20">
        <p class="login-password">
            <label for="user_pass">Password</label>
            <input type="password" name="pwd" id="user_pass" class="input" value="" size="20">

        <p class="login-submit">
            <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary" value="Log In"></form>

How can I set it to redirect to the current page after login (again this form pops up in a modal)? I thought that I would have been able to use the standard redirect url parameter, but it still redirects straight to /wp-admin.

1 Answer 1


You can try adding a hidden input field which has the value of the current page where the modal is triggered. Just add the following code below inside the form.

<input type="hidden" name="redirect_to" value="'<?php echo site_url( $_SERVER['REQUEST_URI'] );?>" />

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.