Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter DivaVocals

    (@divavocals)

    So I fixed part of the issue..
    Changed line 137 of wp-login/wp-login.php as follows:

    if($_SERVER['SCRIPT_NAME']=="<?php home_url('/'); ?>wp-login.php"):

    Changed line 586 of wp-login/wp-login.php as follows:

    <?php home_url('/'); ?>wp-login.php" target="_blank" class="btn">View Your Login Page</a>

    This now correctly calls the blog homepage regardless of whether or not WordPress is installed in the site root or in a subfolder in the root.

    However, the login page still does not apply my theme correctly.. There has to be one more place in this file that is not correctly calling the blog homepage and defaulting to the site root instead..

    Grrrrrrrrrrrrrr…..

    Thread Starter DivaVocals

    (@divavocals)

    So after looking at this a little while longer, I figured out that the issue is that wp-login/wp-login_modified.php also is not making use of the home_url template tag so that this plugin properly retrieves the home url.

    So while changes I made above gets the login page preview to correctly grab the path to wp-login.php, the functionality which is supposed to display my wp-login.php inside my login page (and therefore be format the login page to look like the rest of my site) is not working. It’s WAY over my paygrade to fix this.. I think I know where the code changes need to go, but am unsure how to properly make them myself. **LOL**

    Conclusion: The plugin as written currently will work the way it’s supposed to work ONLY on sites where WordPress is installed in the root of the site (https://www.mysite.com/), but not in a subfolder inside the root (https://www.mysite.com/myblog/).

    Eric Stoltz has indicated to me via e-mail that an update to this plugin will be forthcoming:

    Just saw your comments on our blog. I will be submitting a fix for this this week.

    That’s awesome news.. So stay tuned.. ??

    Thread Starter DivaVocals

    (@divavocals)

    Well I figured out how to get this to work for now.. I added a new function to my theme’s functions.php file as follows:

    add_action('init','possibly_redirect');
    function possibly_redirect(){
     global $pagenow;
     if( 'wp-login.php' == $pagenow ) {
      wp_redirect('https://www.mysite.com/myblog/login');
      exit();
     }
    }

    This now properly redirects the wp-login.php page to my custom login page. I’m sure there is a better way to do this, but this works and I’m moving on.. Hopefully at some point this plugin will be updated to work correctly. In the meantime, my two hacks seem to be working just fine..

    That said I did note that the custom login page still shows the login form even when you are logged in.

    Thread Starter DivaVocals

    (@divavocals)

    Had to make some modifications to my custom functions.. and now I have everything redirecting correctly using this plugin.. So.. my ENTIRE fix altogether now..

    STEP ONE:
    Changed line 137 of wp-content/plugins/wp-login/wp-login.php as follows:

    if($_SERVER[‘SCRIPT_NAME’]==”<?php home_url(‘/’); ?>wp-login.php”):

    Changed line 586 of wp-content/plugins/wp-login/wp-login.php as follows:

    <?php home_url(‘/’); ?>wp-login.php” target=”_blank” class=”btn”>View Your Login Page

    This now correctly calls the blog homepage regardless of whether or not WordPress is installed in the site root or in a subfolder in the root.

    STEP TWO
    Add the following to your theme’s functions.php file.

    add_action('init','possibly_redirect');
    function possibly_redirect(){
     global $pagenow;
     if(!is_user_logged_in() && ( 'wp-login.php' == $pagenow )) {
      wp_redirect('https://www.mysite.com/myblog/login'); // modify this as you wish
      exit();
     }
    }
    
    add_filter('logout_url', 'custom_logout_home', 10, 2);
    function custom_logout_home($logouturl, $redir)
    {
    	$redir = get_option('siteurl');
    	return $logouturl . '&redirect_to=' . urlencode($redir);
    }
    
    add_filter('login_redirect', '_catch_login_error', 10, 3);
    function _catch_login_error($redir1, $redir2, $wperr_user)
    {
        if(!is_wp_error($wperr_user) || !$wperr_user->get_error_code()) return $redir1;
        switch($wperr_user->get_error_code())
        {
            case 'incorrect_password':
            case 'empty_password':
            case 'invalid_username':
            default:
                wp_redirect('/myblog/login'); // modify this as you wish
        }
        return $redir1;
    }

    These custom functions do the following:

    =======================================================================

    It’s not a perfect solution, but these changes do make this plugin workable now.. I may do some more picking to figure out how to show the correct login state when accessing the login page after you are already logged in. (Currently the admin toolbar is your only hint that you are logged in)

    My posts on the author’s blog regarding this issue have ALL been removed.. **shrug** So I will continue to post my updates here on the WordPress forum in case anyone using this plugin has the same issue. This way they can try my workaround until the author updates this plugin..

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘[Plugin: WP Login] Plugin doesn't appear to work if your blog is in a folder’ is closed to new replies.