-
Author
-
August 17, 2013 at 15:20 #1473clutchnycParticipant
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=%2Fbrowser 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!!!!
TimAugust 18, 2013 at 17:05 #1487clutchnycParticipantI 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!
August 20, 2013 at 22:59 #1618SQadminKeymasterHi,
Maybe it works this way to redirect. Add the following code to sweetdate-child/functions.phpCOPY CODEadd_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 solutionAugust 21, 2013 at 00:10 #1624clutchnycParticipantThanks so much! I’m all set now. I really appreciate your help.
Tim
-
AuthorPosts
The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.