0

I have changed the wp_login.php name with a plugin

I have a custom login and this is mandatory from my webhost because they want to make sure their servers are secure.
The use of their suggested plugin isn't mandatory but they just won't allow the use of wp_login.php

Anyhow this plugin wants me to rename the wp_login to whatever. So for the sake of argument lets call the page whatever

I now want to redirect users to this page if they are not logged in and come to this page. I can use a basic wp_redirect function I found online but this doesn't work:

function restrict_access_if_logged_out(){
    if (!is_user_logged_in() && !is_home()){
        $redirect = home_url() . '/wp-login.php?redirect_to=' . urlencode( $_SERVER['REQUEST_URI'] );
        wp_redirect( $redirect );
        exit;
    }
}
add_action( 'wp', 'restrict_access_if_logged_out', 3 );

I changed the wp_login.php to whatever page

It redirects me to the login page but not back to the page the user came from.
The URL does hold the value it should from where the user came.

Any ideas how to fix this?

  • 1
    this is a plugin specific question and therefor off-topic, and the plugin is unmaintained so best thing is just not to use it. But any hosting service that tells you how to name your files is not a place you should work with. – Mark Kaplun Oct 21 '15 at 16:32
  • How is this off-topic if I create the topic? Anyhow I can't change the hosting service and need to work with the tools I've got. So is there a solution for this that is manageable? – Interactive Oct 22 '15 at 6:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.