This topic has 5 replies, 3 voices, and was last updated 11 years by kswift.

  • Author
  • #1473
     clutchnyc
    Participant

    Hi, I just launched my site last night. one issue that came up.

    when I use the modal window to log in, I enter my user name & password and click “log in”,

    I then go to this URL:
    http://www.urbansake.com/wp-login.php?redirect_to=%2F

    browser says “can’t open page”

    This happens in all browsers and I’ve tried clearing cache and cookies.

    If I go directly to http://www.urbansake.com/wp-login.php and log in from there, I have no problem. I didn’t have this log in issue when I tested my site on staging before going live, so I’m not sure what is causing this issue. If you have any ideas, please let me know. It must be some kind of redirect issue, but haven’t been able to figure it out yet.

    thank you!!!!
    Tim

    #1487
     clutchnyc
    Participant

    I found out this is related to my webhost: WPengine. They have restrictions on how custom log-ins must be coded. This may be useful if you have other customers who use WPengine like I do.

    In the file page-parts/general-login-modal.php they had me change
    <form action="<?php echo wp_login_url(apply_filters('kleo_modal_login_redirect', '') ); ?>"
    to
    <form action="<?php echo esc_url( site_url( 'wp-login.php', 'login_post' ) ); ?>"

    Here is the background info that WPengine sent me:

    The problem on our platform comes from when the form is hardcoded directly to “wp-login.php”. Here’s some example code from a similar issue:
    <form action=”<?php echo get_option(‘home’); ?>/wp-login.php?redirect_to=<?php echo urlencode($_SERVER[‘REQUEST_URI’]); ?>” method=”post”>
    To compare, here’s what WordPress uses in the “wp-login.php” file:
    <form name=”loginform” id=”loginform” action=”<?php echo esc_url( site_url( ‘wp-login.php’, ‘login_post’ ) ); ?>” method=”post”>
    The most important part of the code from “wp-login.php” file is this portion:
    site_url( ‘wp-login.php’, ‘login_post’ )
    Our security measures rely on modifying the “site_url()” function when the second part of that function is “login_post”. If you’re not using the “site_url()” function, or if you’re are using the “site_url()” function but not “login_post”, then the custom login form is going to run into our security block.
    Our engineers have recommended to modify the code to generate the login URL the same way that WordPress does because our system reads the direct call to wp-login.php.

    So, I’m now able to log on using the custom modal window, but this function you gave me to keep users on the same page they are on when they log on doesn’t work anymore. everyone gets redirected to the homepage upon login. Can you suggest an update that might work given that I can’t use $_SERVER[‘REQUEST_URI’]?

    add_action('after_setup_theme','kleo_my_actions');
    function kleo_my_actions() {
    add_filter('kleo_modal_login_redirect','my_custom_redirect');
    }
    function my_custom_redirect() {
    return $_SERVER['REQUEST_URI'];
    }

    thanks!

    #1618
     SQadmin
    Keymaster

    Hi,
    Maybe it works this way to redirect. Add the following code to sweetdate-child/functions.php

    COPY CODE
    
    add_filter('login_redirect', 'redirect_previous_page', 10);
    
    function redirect_previous_page(){
        $request = $_SERVER["HTTP_REFERER"];
        $req = explode(get_option('siteurl'),$request);
        if (isset($req[1])){
            $redirect = site_url( $req[1], 'login_post' );
        } else {
            $redirect = site_url( '', 'login_post' );
        }
    
    
        return $redirect;
    }
    

    PS: Thanks for the awesome comment 🙂

    Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution
    #1624
     clutchnyc
    Participant

    Thanks so much! I’m all set now. I really appreciate your help.

    Tim

    #1756
     kswift
    Participant

    Hi Tim, checked out your website, real nice implementation of this theme!
    I was trying to see how you made the register form be invisible until one clicks the register button, and how you created that animated effect! Is that a lot of custom code?

    #1766
     kswift
    Participant

    Oh never mind, I found that it’s default behaviour for the login/signup buttons, so I’ll use that!

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

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?