Forums

[WP-Authenticate] Authentication plugins not compatible with 2.6 (15 posts)

  1. abinidi
    Member
    Posted 1 year ago #

    I just upgraded to 2.6, and I've discovered that the various plugins that are used to require authentication don't work with 2.6, and I'm guessing it is because of the way cookies were changed in 2.6. However, I don't know enough to fix the problem.

    Does anybody have any suggestions on where I can look? Basically I'm either needing help fixing the code to check for the correct "logged-in" cookie, or I need help finding a new plugin (2.6 compatible, obviously) that allows me to require users to log in in order to see content on the blog.

    Here is the old code for the plugin. I'm guessing a fix is probably pretty simple:

    class wpAuthenticate {
        /**
         * If the current page isn't 'wp-login.php' or 'wp-register.php', ensure the
         * user is logged in.
         *
         * @return void
         */
        public static function check_auth_to_read () {
            //If the current page isn't 'wp-login.php' or 'wp-register.php' redirect
            if ((strpos($_SERVER['PHP_SELF'], 'wp-login.php') === false) && (strpos($_SERVER['PHP_SELF'], 'wp-register.php') === false)) {
                auth_redirect();
            }
        }
    }

    Thanks for your help

  2. twothirty
    Member
    Posted 1 year ago #

    i second that. i use an authentication plugin that no longer works in 2.6 "Angsuman's Authenticated WordPress Plugin".

  3. Anonymous
    Unregistered
    Posted 1 year ago #

    I third that. I'm going through the code, I'll post here if I can get it working.

    Thanks,

    Pamela

  4. Anonymous
    Unregistered
    Posted 1 year ago #

    I quadruple that :)

    I run a private blog that I've had to disable completely until this gets fixed :(

  5. Anonymous
    Unregistered
    Posted 1 year ago #

    Hey guys, there is a fix posted at the plugin home site (http://xavisys.com/wordpress-authentication-plugin/):

    # July 18th, 2008 at 5:05 pm
    bread Says:

    In my case, I modified wp-authenticate.php by this:

    if ((strpos($_SERVER['PHP_SELF'], ‘wp-login.php’) === false) && (strpos($_SERVER['PHP_SELF'], ‘wp-register.php’) === false)) {
    if ( !is_user_logged_in() ) {
    auth_redirect();
    }
    }

    Then, it works with WP 2.6.

    Hope that helps at least for this one plugin.

    Pamela

  6. Anonymous
    Unregistered
    Posted 1 year ago #

    Be careful though. It is easy to goof that up (I wasn't the only one). You are really only adding the second if statement.

    Hopefully this will help:

    Look at this code here (from the plug in site):

    if ((strpos($_SERVER['PHP_SELF'], ‘wp-login.php’) === false) && (strpos($_SERVER['PHP_SELF'], ‘wp-register.php’) === false)) {
    auth_redirect();
    }

    Now, Make it look like this:

    if ((strpos($_SERVER['PHP_SELF'], ‘wp-login.php’) === false) && (strpos($_SERVER['PHP_SELF'], ‘wp-register.php’) === false)) {
    if ( !is_user_logged_in() ) {
    auth_redirect();
    }
    }

    that should clear it all up, doing this made it work like a charm for me.

  7. Anonymous
    Unregistered
    Posted 1 year ago #

    hi bwakefield, I made the change and I cannot activate the plugin in WordPress 2.6

    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /hermes/bosweb/.../blog/wp-content/plugins/wp-authenticate.php on line 23

    line 23 = “public static function check_auth_to_read () {”

  8. mosey
    Member
    Posted 1 year ago #

    Perhaps you can post your complete edit of that section? It just looks as though a } is missing, as per the error message.

  9. Anonymous
    Unregistered
    Posted 1 year ago #

    Error when activate the following plugin:
    Parse error: syntax error, unexpected T_STRING, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or '}' in /hermes/bosweb/web031/b313/sl.adejeffc/public_html/blog/wp-content/plugins/wp-authenticate.php on line 12

    the following is the whole file of the plugin:

    <?php
    /**
    * Plugin Name: Authenticate
    * Plugin URI: http://xavisys.com/wordpress-authentication-plugin/
    * Description: Instantly requires that users be logged in to visit your site. Also serves as a good base for expansion. No interface, just activate and go!
    * Author: Aaron Campbell
    * Version: 1.0.0
    * Author URI: http://xavisys.com/
    */
    class wpAuthenticate {

    public static function check_auth_to_read () {
    if ((strpos($_SERVER['PHP_SELF'], ‘wp-login.php’) === false) && (strpos($_SERVER['PHP_SELF'], ‘wp-register.php’) === false)) {
    if ( !is_user_logged_in() ) {
    auth_redirect();
    }
    }
    }
    }
    }

    add_filter('init', array('wpAuthenticate','check_auth_to_read'));

  10. mosey
    Member
    Posted 1 year ago #

    Thanks. Try removing an extra } perhaps? There are 4x { tags as far as I can see, and 5x } ones.

  11. sindark
    Member
    Posted 1 year ago #

    I have stopped updating my private blog, since every new version of WordPress seems to break Angsuman's Authenticated WordPress Plugin.

  12. Anonymous
    Unregistered
    Posted 1 year ago #

    turns out it's because my server php version is 4.4.7
    so it doesn't recognize the public static

    my code looks like the following now and I can activate it
    However, when I go to my blog index page (not log in yet), the page is blank :X

    <?php
    /**
    * Plugin Name: Authenticate
    * Plugin URI: http://xavisys.com/wordpress-authentication-plugin/
    * Description: Instantly requires that users be logged in to visit your site. Also serves as a good base for expansion. No interface, just activate and go!
    * Author: Aaron Campbell
    * Version: 1.0.0
    * Author URI: http://xavisys.com/
    */
    class wpAuthenticate {

    function check_auth_to_read () {
    if ((strpos($_SERVER['PHP_SELF'], ‘wp-login.php’) === false) && (strpos($_SERVER['PHP_SELF'], ‘wp-register.php’) === false)) {
    if ( !is_user_logged_in() ) {
    auth_redirect();
    }
    }
    }
    }

    add_filter('init', array('wpAuthenticate','check_auth_to_read'));
    ?>

  13. croila
    Member
    Posted 1 year ago #

    I've upgraded to 2.6 and when I use the code adejeffchen pasted in above, I just get a kind loop of permanent redirecting without it getting anywhere!

    Does anyone know of any other plugins like this which work with WP2.6?

  14. kraucrow
    Member
    Posted 1 year ago #

    I also get loop of permanent redirecting. Did anyone come up with the solution to it?

  15. kraucrow
    Member
    Posted 1 year ago #

    The problem was with '
    That's the plugin that works with 2.6:
    http://marius.php.lt/project/wp-auth/wp-authenticate.php.txt

Topic Closed

This topic has been closed to new replies.

About this Topic