Skip to content
Read For Learn
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP
Read For Learn
  • Database
    • Oracle
    • SQL
  • C
  • C++
  • Java
  • Java Script
  • jQuery
  • PHP

Change username before login

You can use wp_authenticate filter for that… This filter is fired before the user is authenticated. Params are passed by reference, so you can modify them.

// user name is passed in by reference 
function wp_authenticate_by_email( &$username ) {
    // make sure that the condition below works for you
    if ( is_numeric( $username ) && '0' == substr( $username, 0, 1 ) ) {
        $username = substr( $username, 1 );
    }
}
add_action( 'wp_authenticate', 'wp_remove_leading_zero_from_phone_number' );

Related Posts:

  1. Change “You are now logged out” text
  2. Removing labels and tag on WordPress’s default login form
  3. Customize user account activation message
  4. add filter login_redirect does not contain original requested redirect
  5. Filters on Login Page
  6. How do I hook my function to run only after submitting login form
  7. Change password reqts with NO plugin without breaking resetpass link?
  8. WordPress hooks/filters insert before content or after title
  9. How do filters and hooks really work in PHP
  10. Trouble understanding apply_filters()
  11. How many filter/action hooks are healthy?
  12. Filter specific shortcode output?
  13. Earliest hook to reliably get $post/$posts
  14. How to pass/get data to/from the WooCommerce data-product_variations object?
  15. Where to hook into post content?
  16. What does (10, 2) mean when used with add_filter
  17. Filter username field on registration for profanity and unwanted words
  18. Clarification on filters and hooks
  19. Valid characters for actions, hooks and filters
  20. How to hook into unregistering a widget instance?
  21. How to check if a hook is hooked or not?
  22. Editing ‘Password Reset’ E-mail
  23. Passing Additional Parameters to add_filter Callable
  24. What hook do I use to edit the post statuses option in admin?
  25. Filter hook before create order WooCommerce
  26. Modify WordPress Rest Api Request/Response
  27. How to add some custom HTML into wordpress admin bar?
  28. Custom theme hooks / filters – passing arguments
  29. wp_mail – Remove sitename from email subject
  30. How to disable all WordPress emails modularly and programatically?
  31. How to hook wp_list_pages?
  32. apply_filters() slices away needed arguments
  33. WP Rest API – Upload media without saving attachment post
  34. How to make post and comment count unclickable with dashboard_glance_items hook
  35. How to use the_excerpt in a filter hook?
  36. Change the footer text on the login page
  37. How to add attribute to output with wp_video_shortcode add_filter
  38. How to change Woocommerce breadcrumbs content?
  39. Hook into admin post list page
  40. Anyway to edit the titlebar of WordPress Widgets in the Admin area?
  41. How to limit the pages displayed for choosing parent page on page attribute’s menu?
  42. How can I hide all posts that don’t have a thumbnail?
  43. Change text of Description in Image Library
  44. Load different template file when condition met?
  45. How can I do customizations on login, registration and password recovery forms?
  46. Am I using the right hook for removing quicktags on the admin TinyMCE?
  47. About Hooks and Filters
  48. How to enable visual editor when editing comments on the dashboard?
  49. Should I use add_action(‘publish_post or add_filter(‘publish_post?
  50. Please explain me what the do_action does
  51. Is it possible to Hook/Filters Attachment Creation?
  52. Filter all html output
  53. Can’t get wp_title filter working in twenty sixteen child theme
  54. How can I reliably and globally disable wptexturize?
  55. Customise Jetpack Publicize text
  56. WordPress RSS feed – filter RSS content by custom field value
  57. How to trigger the core WPLANG to make automatically set a language when the theme is activated? [duplicate]
  58. How to hook some Unicode texts into calendar widget safely?
  59. How to add attributes to tag when template cannot be directly modified
  60. filter the_title problem in nav
  61. How can I add a fifth option to the alignment picker?
  62. Too many actions/filters!
  63. Filter the URL of next_posts_link & previous_posts_link
  64. How to get list of all hooks of current theme / plugin?
  65. Which hook is fired when inserting media into a post
  66. How to replace any occurence of Gravatars with a local placeholder image?
  67. How does WordPress call functions attached to a certain action hook before calling functions attached to other hooks
  68. Sensei LMS Hooks to Remove Content
  69. What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?
  70. Conditionally call add_action depending on post_type?
  71. How do we check if the user is logging in or registering?
  72. Customizing the default logout page of WordPress
  73. Change WordPress RSS link with filter?
  74. WordPress tag cloud add more links
  75. Add a header before fields added with the attachment_fields_to_edit() filter
  76. Error when overriding only some audio shortcode HTML output
  77. Hide content editor for posts after approriate date
  78. Why anything done on comments_array hook gets reset?
  79. Gutenberg disable the “block” tab in right sidebar
  80. Why my admin doesn’t work after adding rest_prepare_post filter?
  81. add_filter() function misunderstanding
  82. Is it possible to track down Actions and Filters?
  83. When to use actions and when to use filters
  84. add_filter to ‘woocommerce_before_main_content’ [closed]
  85. Yoast SEO hooks overriding themselves
  86. Editing
  87. Is possible dequeue/remove style from wp_footer() hook and add on wp_head() hook?
  88. Same Conditionals Not Working on Two Different Hooks
  89. Filter or Hook to catch pre-rendering of post content
  90. How to call a function or method that is Namespaced using another plugin
  91. get_header and hook avoid normal call
  92. Question about how do wordpress filters/actions work
  93. How to center oEmbedded content
  94. How to add numeric slug for child page in WordPress 5.9?
  95. Can the wp_filter object hold multiple values with the same key
  96. check to see if hook is available
  97. How to change the order (priority) of registered filters (or actions) (e.g. for the_content)?
  98. apply_filters/do_action tag characters limit
  99. Custom Login Errors and variables I can use
  100. How do I target a single page to modify the comment form of only that page?
Categories filters Tags filters, hooks, login, username, wp-login-form
xdebug connects but won’t break in WordPress with vvv
how to fix Warning: Use of undefined constant _ – assumed ‘_’ (this will throw an Error in a future version of PHP)

Recommended Hostings

Cloudways: Realize Your Website's Potential With Flexible & Affordable Hosting. 24/7/365 Support, Managed Security, Automated Backups, and 24/7 Real-time Monitoring.

FastComet: Fast SSD Hosting, Free Migration, Hack-Free Security, 24/7 Super Fast Support, 45 Day Money Back Guarantee.

Recent Added Topics

  • Bug in translation system: load_theme_textdomain() returns true, files are available and accessible but the language defaults to english
  • Custom Elementor controls not appearing in the widget Advanced tab using injection hooks
  • Get the name of the template/*html file used
  • Trying to Add Paging to Single Post Page
  • Sharing media files between live and staging servers
  • How to display the description of a custom post type in the dashboard?
  • Critical error on image display
  • Copying WP data and files into new install?
  • How to determine the DirectAdmin WordPress backup date?
  • How to get list of ALL tables in the database?
© 2026 Read For Learn
  • Database
    • Oracle
    • SQL
  • algorithm
  • asp.net
  • assembly
  • binary
  • c#
  • Git
  • hex
  • HTML
  • iOS
  • language angnostic
  • math
  • matlab
  • Tips & Trick
  • Tools
  • windows
  • C
  • C++
  • Java
  • javascript
  • Python
  • R
  • Java Script
  • jQuery
  • PHP
  • WordPress