• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Store
    • Cart
    • Checkout
  • Blog
    • Basics [Free]
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Contact
  • Sign In
  • Show Search
Hide Search
Home » Filters » Login with Username or Email

Login with Username or Email

Chad Butler · Dec 1, 2018 ·

This article is provided free. Find out how you can get full access to premium content, including how-to articles and support forums, as well as priority email support and member exclusive plugin extensions..

 

Part of the WP-Members 3.2 project involved allowing users to log in using either their username or their email address. This makes the WP-Members Email as Username extension obsolete (which, if you’re wondering, is why it is no longer supported).

However, because all of the translation files still reflect “Username” in the login form field text, I decided to give the translators time to catch up on the language packs.  So while you can log in using either a username or an email address, the label on the form only says “Username.”  

If you would like to change that, it just requires a simple filter you can add to your theme’s functions.php file:

/**
 * The plugin currently allows login using Username OR Email but
 * the field label still reflects just username (that will be
 * changing when translators catch up on translation). In the 
 * meantime, you can change it with a couple of filters added
 * to your theme's functions.php file.
 */
add_filter( 'wpmem_inc_login_inputs', function( $defaults ) {
    $defaults[0]['name'] = "Username or Email";
    return $defaults;
});
add_filter( 'wpmem_sidebar_form', function( $html ) {
    if ( ! strpos( $html, 'Username or Email' ) ) {
        $html = str_replace( 'Username', 'Username or Email', $html );
    }
    return $html;
});

Filters wpmem_inc_login_inputs, wpmem_sidebar_form

Welcome to RocketGeek Interactive › Forums › Login with Username or Email

  • This topic has 2 replies, 2 voices, and was last updated 1 year, 4 months ago by Chad Butler.
Viewing 1 reply thread
  • Author
    Posts
    • December 1, 2018 at 9:57 am #16728
      Chad Butler
      Keymaster

      Part of the WP-Members 3.2 project involved allowing users to log in using either their username or their email address. This makes the WP-Members Ema
      [See the full post at: Login with Username or Email]

    • September 10, 2019 at 8:44 am #19848
      ituk
      Participant

      This is very nice to know that the plugin is no longer needed, but after removing it i encountered an issue in the registration process. The thing is i don’t want users to register with a username, only with an email, so I hide the username field with css. it was possible with old plugin because the username field in the registration form wasn’t set as required. after deactivating the plugin it became impossible to register because the required field was hidden. I got this error:
      An invalid form control with name='username' is not focusable.

      Thanks,
      Itamar

      • September 11, 2019 at 8:55 am #19887
        Chad Butler
        Keymaster

        The bottom line is that WP requires a username for a valid user, so at the core level it’s not possible to omit it.

        The Email as Username extension overcame this by setting the user’s username as the user’s email address. However, that was not a very clean process in my opinion because WordPress does not allow for the username to be changed. So if a user updated their email address, the extension had to fire a direct SQL query to change the username to the new email address directly, otherwise the username and new email wouldn’t match.

        The current versions of WP-Members allow login with username or email address. This is different than setting the email AS the username.

        If you want to use the new process but eliminate the username altogether, there would be ways to customize that, but you’d essentially be recreating what’s already in the Email as Username extension. So you may as well use the extension – otherwise, we’re just creating the same process as a customization.

        Hope that helps.

  • Author
    Posts
Viewing 1 reply thread
  • You must be logged in to reply to this topic.
Log In

Ready to get started?

Join Today!

© 2021 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Refund Policy