17 thoughts on “Auto-login Script for WordPress

  • April 2, 2017 at 7:57 AM
    Permalink

    HI Drew, i like your script. Im looking around and found yours the best. However im facing some issue when i run the url, Im not getting anything and the status code is 500 Internal Server Error.

    Reply
  • June 15, 2017 at 10:28 AM
    Permalink

    I experienced the same thing, and the path seems to be correct…

    I’ll send you the link through contact form… great script, nice solution

    Reply
  • June 15, 2017 at 10:41 AM
    Permalink

    I’m getting this error now

    Parse error: syntax error, unexpected ‘$user’ (T_VARIABLE) in **REMOVED**/auto-login.php on line 31

    also looking at your code below, … just looking at the bracket before wp-blog-header, if that is correct

    require( dirname( __FILE__ ) . ‘(wp-blog-header.php’ );

    Reply
    • June 15, 2017 at 10:44 AM
      Permalink

      Does the user exist? If not, that’s going to throw an error.

      I’m going to edit your note too. Please don’t include info that would show the path to your script on your server.

      Reply
          • June 15, 2017 at 1:33 PM
            Permalink

            Hi Ed — OK, so, I have an issue with my contact form, I’ll fix that, thank you very much. I’ll take a look this evening at the script and do an implementation with a new site to be sure my directions aren’t missing something. I’ll get back to you later tonight or tomorrow. Thanks!

    • June 15, 2017 at 2:49 PM
      Permalink

      Ahhh — figured out the issue, sorry about this. On the line for $username, add a semicolon to the end so that it’s this:

      $username = esc_sql($_REQUEST[‘u’]);

      In the lines above for setting the path, if it is the root directory that you are putting the file, use —

      require( dirname( __FILE__ ) . ‘wp-blog-header.php’ );

      if you are putting it in a separate subdirectory, this should work —

      require( dirname( __FILE__ ) . ‘./../wp-blog-header.php’ );

      Reply
      • June 17, 2017 at 1:24 AM
        Permalink

        thanks a million, will test this

        Reply
        • June 17, 2017 at 1:38 AM
          Permalink

          Hi.

          l just tested . there are no errors. again but it doesn’t log me in though

          it just redirects to home page

          Reply
          • June 17, 2017 at 5:56 PM
            Permalink

            It sounds like the user does not exist — note the code will ALSO redirect to the home page remove the cookies if you use a username value that doesn’t exist.

            //If user doesn’t exist, clears the cookie and redirects to home

            You could change that line below to another URL to validate this.

            Is the user you are attempting to login as any level other than subscriber? The script also prevents this for security reasons. You could increase this to any level you wish by changing the line with “subscriber” in it.

            You can reach me via my contact form now if you want to give me a link to your site.

  • June 15, 2017 at 11:16 AM
    Permalink

    I tried to use your contact form and got this

    Failed to send your message. Please try later or contact the administrator by another method.

    Reply
    • June 15, 2017 at 2:15 PM
      Permalink

      Thanks for the heads up! This is fixed. Contact Form 7 is apparently no longer working for my hosting provider. Ouch!

      Reply
    • August 15, 2017 at 9:07 PM
      Permalink

      Thanks. Yes, I believe another variable could be passed that would then redirect the user. I’ll play with that and let you know in a few days.

      Reply
    • August 17, 2017 at 8:37 PM
      Permalink

      Hi Dale — I’ve got an update for you — have a look at the V2 script linked in the post now. There are directions and more information about usage in the script’s comments.

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *