Redirect to custom login page

This topic contains 6 replies, has 4 voices, and was last updated by  Alex Rollin 6 years, 1 month ago.

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket
  • Author
    Posts
  • #2121

    James Gehring
    Buyer
    Post count: 34

    I am using the shortcode to create the button. When you click on it when logged out it takes you to the default WordPress login. Is there a way to redirect to a custom page?

    #2123

    Guust
    Moderator
    Post count: 29970

    I’ll get a developer to have a look at your question.
    Thanks

    #2126

    Patrik
    Moderator
    Post count: 1971

    Hi James,

    We need more information on the problem you have. Can you please explain in details with steps or example? It would be great if you can provide your website admin login details in private reply to look more into this.

    Regards,
    Patrik

    #2133

    James Gehring
    Buyer
    Post count: 34
    This reply has been marked as private.
    #2134

    Patrik
    Moderator
    Post count: 1971

    Hi James,

    You can use the following code in your functions.php file of the currently active theme:

    
    
    add_filter( 'login_url', 'login_url_cb', 10, 2 );
    function login_url_cb($login_url, $redirect){
        $login_page_id = uwp_get_page_id('login_page', false);
        $redirect_page_id = uwp_get_option('login_redirect_to', -1);
        if ($login_page_id) {
            $login_page = get_permalink($login_page_id);
            if($redirect){
                $login_url = add_query_arg( 'redirect_to', $redirect, $login_page );
            }elseif(isset($redirect_page_id) && (int)$redirect_page_id == -1 && wp_get_referer()) {
                $redirect_to = esc_url(wp_get_referer());
                $login_url = add_query_arg( 'redirect_to', $redirect_to, $login_page );
            }elseif($redirect_page_id){
                $redirect_to = get_permalink($redirect_page_id);
                $login_url = add_query_arg( 'redirect_to', $redirect_to, $login_page );
            }else{
                $login_url = $login_page;
            }
        }
    
        return $login_url;
    }

    Let me know if it works for you or not.

    Regards,
    Patrik

    #2140

    James Gehring
    Buyer
    Post count: 34

    That worked. Thanks

    #2142

    Alex Rollin
    Moderator
    Post count: 27815

    Thank for letting us know! 🙂

Viewing 7 posts - 1 through 7 (of 7 total)

We have moved to a support ticketing system and our forums are now closed.

Open Support Ticket