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

How do I hook my function to run only after submitting login form

The filter runs on every page load, but the first argument will be a WP_User object only on successful submission. It will be null if nothing was submitted, but most likely it will be a WP_Error object, which you can check for. If you want to know the specific error you have to look at the errors the object contains. The case where the form was not submitted will have both empty_username and empty_password error array keys.

This will possibly shed some light on things:

function myplugin_auth_signon( $user, $username, $password ) {
    var_dump( $user );
    return $user;
}
add_filter( 'authenticate', 'myplugin_auth_signon', 30, 3 );

Load the page, then try various combinations of incorrect and empty values, then a correct login.

Related Posts:

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

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