We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32667
    • 38 Posts
    Has anyone done this?

    I’m using WebloginPE, which rocks, but would like to allow users to login with both their email address or username.
      • 32667
      • 38 Posts
      Ok this was actually cake when I looked at it.

      In webloginpe.class.php, around line 2400 in the QueryDbForUser class, I changed the $query to:

      $query = "SELECT * FROM ".$web_users.", ".$web_user_attributes.", ".$this->CustomTable." WHERE BINARY ( LOWER(".$web_users.".`username`) = '".strtolower($Username)."' OR " . $web_user_attributes . ".`email` = '" . strtolower($Username) . "') AND ".$web_user_attributes.".`internalKey` = ".$web_users.".`id` AND ".$this->CustomTable.".`internalKey` = ".$web_users.".`id`";
      


      Users often don’t remember their username and try to use email.

      Now they can use either!
        • 26310
        • 130 Posts
        I changed that line but am a little confused on this. So do we hide the username field? How do you make that NOT required for registration.

        I read about using the javascript solution to juse add the value of the email to the username but I guess I missed whether or not that’d work on someone who has javascript disabled.

        Basically what I’m asking is on the registration form, do we hide one of the fields? Thanks for the help.
          I twitch because I care....and drink too much coffee.
          • 26310
          • 130 Posts
          Can anyone confirm the above solution? Anyone out there...... huh
            I twitch because I care....and drink too much coffee.
            • 29774
            • 386 Posts
            You can hide the username in the sign up form but you need to ensure that the username is set to the value of the email in the $_POST array when the form is submitted, ie:

            $_POST[’username’] = $_POST[’email’];

            Add this to the Register() function in webloginpe.class.php right at the top of the function.

              Snippets: GoogleMap | FileDetails | Related Plugin: SSL
              • 26310
              • 130 Posts
              That worked perfectly thanks! Now if I could only get my custom fields to save to the DB I’d be one happy camper grin
                I twitch because I care....and drink too much coffee.