login - Log in only by email and no username

Can you tell me a function to insert in the functions.php file to remove the login via username option?I would like the

Can you tell me a function to insert in the functions.php file to remove the login via username option?

I would like the user to be able to log in only with his registered email.

Can you tell me a function to insert in the functions.php file to remove the login via username option?

I would like the user to be able to log in only with his registered email.

Share Improve this question edited Sep 16, 2019 at 13:16 Matthew Brown aka Lord Matt 1,0683 gold badges13 silver badges34 bronze badges asked Sep 16, 2019 at 11:45 Matteo FeduziMatteo Feduzi 291 silver badge9 bronze badges 4
  • I assume you are looking for the filter authenticate: codex.wordpress/Plugin_API/Filter_Reference/authenticate – Matthew Brown aka Lord Matt Commented Sep 16, 2019 at 12:08
  • I think so, can you give me the exact code to allow users to access only via email and password? Without using the username? Thanks – Matteo Feduzi Commented Sep 16, 2019 at 12:57
  • 3 Keep in mind that embedding this in the theme will mean on any theme change it'll be impossible to login as nobody would know their usernames. Put it in an mu-plugin or a normal plugin. It'll be just as fast, except now it'll work for all themes, and can be copied between sites easily. Putting functionality like this inside a theme is very bad practice, themes should only contain visuals/styles/templates – Tom J Nowell Commented Sep 16, 2019 at 13:17
  • Hi, @MatteoFeduzi, I'm glad I could help you progress towards a solution. You may not be aware but the community is not terribly fond of "write my code" questions seeing them as "do my homework for me". See this discussion for a more in-depth look at question and answer standards regarding code. – Matthew Brown aka Lord Matt Commented Sep 16, 2019 at 14:20
Add a comment  | 

1 Answer 1

Reset to default 0

In default-filters you'll see

// Default authentication filters
add_filter( 'authenticate', 'wp_authenticate_username_password', 20, 3 );
add_filter( 'authenticate', 'wp_authenticate_email_password', 20, 3 );

so you just need to

remove_filter( 'authenticate', 'wp_authenticate_username_password', 20 );

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745153200a4613960.html

相关推荐

  • login - Log in only by email and no username

    Can you tell me a function to insert in the functions.php file to remove the login via username option?I would like the

    2小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信