WordPress.org

Ready to get started?Download WordPress

Forums

WP Login
Plugin doesn't appear to work if your blog is in a folder (5 posts)

  1. DivaVocals
    Member
    Posted 2 years ago #

    http://www.mysite.com/myblog/ is how my WordPress site is setup.

    This plugin seems to assume that my WordPress site is in the top level root of the site.. It doesn't look in the blog folder for my blog and therefore not only does the login page preview not work, neither does my themed login page.

    The login page preview directs me to http://www.mysite.com/wp-login.php instead of http://www.mysite.com/myblog/wp-login.php

    What gives??

    http://wordpress.org/extend/plugins/wp-login/

  2. DivaVocals
    Member
    Posted 2 years ago #

    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.....

  3. DivaVocals
    Member
    Posted 2 years ago #

    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 (http://www.mysite.com/), but not in a subfolder inside the root (http://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.. :)

  4. DivaVocals
    Member
    Posted 2 years ago #

    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('http://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.

  5. DivaVocals
    Member
    Posted 2 years ago #

    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('http://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..

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags