Ask the community

This is a community support forum where you can ask
questions and interact with other PremiumPress Customers.

Login with email address or username

  • Shakib
    Shakib
    Newbie 41 points
    July 4, 2013 at 5:13 pm

    Hi,
    Adding below code to your _functions.php will enable your users to login with their email address or username. At the moment one can login only with username.

    function login_with_email_address($username) {
    $user = get_user_by_email($username);
    if(!empty($user->user_login))
    $username = $user->user_login;
    return $username;
    }
    add_action(‘wp_authenticate’,’login_with_email_address’);

    • This topic was modified 6 years, 2 months ago by Mark Fail Mark Fail.
  • David Harris
    David Harris
    Senior Member 367 points
    July 5, 2013 at 5:04 am

    Nice Shakib. +1

  • Mark Fail
    Mark Fail
    Super Guru 12,822 points
    July 5, 2013 at 8:47 am

    thanks for sharing :)

  • Narender Kumar
    Narender Kumar
    Senior Member 273 points
    July 8, 2013 at 5:40 pm

    Can I place it in custom styles box.

  • Shakib
    Shakib
    Newbie 41 points
    July 8, 2013 at 6:03 pm

    Hi,
    No this must go in your _functions.php file in your themes folder. If you don’t have _functions.php file then see attached.
    Copy the file to your theme directory, see example below:

    wp-content\themes\directorypress\themes\directorypress-Glow-Directory\_functions.php

    btw, custom styles box is for css

    Attachments:
    You must be logged in to view attached files.
  • Narender Kumar
    Narender Kumar
    Senior Member 273 points
    July 8, 2013 at 6:16 pm

    Thanks a lot . Iam still in the learning mode ( self Taught). 😀


  • Alexandra
    Newbie 65 points
    July 18, 2013 at 4:39 am

    so can you login with both username or email ?
    or can you only login with email after adding that function ?

  • Mark Fail
    Mark Fail
    Super Guru 12,822 points
    July 18, 2013 at 5:15 am

    try your own site, see which you can do as it seems to be a mixture.

  • CTK
    CTK
    Newbie 26 points
    July 21, 2013 at 10:15 pm

    AWESOME!!! I was looking for a feature like this for our site!!! YEAHHH!!!!

  • Mark Fail
    Mark Fail
    Super Guru 12,822 points
    July 22, 2013 at 1:03 am

    :)

  • Declan
    Declan
    Newbie 41 points
    July 22, 2013 at 3:36 pm

    would this be a different file for coupon responsive?


  • Bhadmus Francis
    Newbie 4 points
    August 1, 2013 at 10:28 am

    please be specific about the exact _function file to edit

  • CTK
    CTK
    Newbie 26 points
    August 4, 2013 at 9:08 pm

    I’m not getting it to work – here’s what I put in to my _functions.php:

    /***LOGIN WITH EMAIL****/

    function login_with_email_address($username) {
    $user = get_user_by_email($username);
    if(!empty($user->user_login))
    $username = $user->user_login;
    return $username;
    }
    add_action(‘wp_authenticate’,’login_with_email_address’);

    ?>

    Is it possible that there’s some variables conflicting? Just looking above, I see plenty of $user variables popping up.

  • Jennifer
    Jennifer
    Senior Member 119 points
    February 16, 2014 at 3:20 am

    This isn’t working for me. I can’t find any syntax errors and tried another similar code block on a WP forum that also didn’t word. Is there a theme conflict? Any suggestions? And along with that, where is the file that allows us to change the text from “username” to “username or email” above the login box? Thanks, Jennifer

  • Mohamed
    Mohamed
    Newbie 24 points
    March 3, 2014 at 12:38 pm

    Hi Jennifer,

    Instal this plugin:

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

    #Worksforme #classifieds

Viewing 15 posts - 1 through 15 (of 17 total)