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

stop login if user_status equal zero

The user_status field isn’t used by core, so you could use it for your own purposes. Although there may be side effects if WP ever decides to reuse it in the future.

The authenticate filter fires before the user is authenticated. You can hook into that filter and return a WP_Error object to prevent the user from logging in.

function wpse_293904_authenticate( $user, $username, $password ) {
  $user_status = get_custom_user_status_from_username( $username );
  if( ! $user_status ) {
    $error = new WP_Error();
    $error->add( 403, 'Oops. Some error message.' );
    return $error;
  }
  return $user;
}
add_filter( 'authenticate', 'wpse_293904_authenticate', 20, 3 );

Related Posts:

  1. Check for user meta data at Login
  2. Should I encrypt the response that triggers an Ajax action? Is nonce sufficient?
  3. user and usermeta table not found
  4. WordPress – Security Question at Login from User’s Meta Data
  5. user_login vs. user_nicename
  6. Difference between update_user_meta and update_user_option
  7. get_user_meta() doesn’t include user email?
  8. Automatically delete inactive users after 2 months
  9. Replacing the WordPress password validation
  10. WordPress auto login after registration not working
  11. How to display the status of users (online – offline) in archive.php
  12. Allow up to 5 Concurrent Login Sessions
  13. How to display custom user meta from registration in backend?
  14. Allowing an email as the username?
  15. Grouping users under parent user
  16. How to create a template for a custom URI associated with the user
  17. How to order users alphabetically by their last name?
  18. Extending WP_User class and using this sub-class during the whole lifecycle
  19. Why does is_user_logged_in() return false after redirect from another site?
  20. Wp_User_Query not sorting by meta key
  21. How we can get the user id by its display_name
  22. WP_User_Query with combined meta query – not working?
  23. How to use hyperdb to separate and share a user dataset between wordpress installs?
  24. LEFT JOIN, INNER OUTER JOIN, LEFT OUTER JOIN is driving me crazy. Please help?
  25. \WP_User Object | What’s the Difference Between {caps} and {allcaps}?
  26. Show Biographical Info while creating new user
  27. include user profiles in search results?
  28. How to add follow functionality to multi-author wordpress site?
  29. Search multiple meta keys at once
  30. Pre-populate Username Field
  31. Where to Store Custom User Fields
  32. Plugin that would allow WordPress Authors to “follow” other Authors and query “Activity Info” from that
  33. Querying Email Addresses for a List of Users with Same Last Name?
  34. Display sortable User meta column in admin panel user’s page
  35. User profile custom field
  36. Front end user meta options for users
  37. How to keep track of user logins?
  38. Get user info outside WordPress
  39. ACF Upload Image in front-end with custom form
  40. How can I secure a WordPress blog using OpenID from a single provider?
  41. Is it possible to get a user with just the password field?
  42. Hide a user from WordPress
  43. Redirect after login based on user role (custom login page)
  44. Drop down list in user profile page
  45. Redirect User to Homepage if no other redirect is specified
  46. My custom page template with is_user_logged_in() does not detect that I’m logged in
  47. Searchable meta value in user.php
  48. How to add country drop down menu to the user profile?
  49. Use phpbb user database for WordPress
  50. Delete user from frontend
  51. WordPress to use Drupal users’ credentials
  52. Add custom fields to the user profile
  53. Share user table from WP with Drupal
  54. Memory usage for scalable usermeta queries
  55. How can I allow password reset based on logins containing the @ character?
  56. A way to count logged in users and display count?
  57. Does wp_delete_user() remove all user content?
  58. WP User Query fails when searching meta queries and search columns
  59. Log all users out of all locations after 24 hours
  60. How can i create an array user meta?
  61. How to set show admin bar front to true for all users?
  62. How do i make my wordpress website private?
  63. Add user data to table when user is created?
  64. User Last Login Sort Column
  65. Updating user meta
  66. WordPress User Meta & ChromePHP or other way to debug/view php variables
  67. Redirect user to login before viewing custom post
  68. Change the user_login at registration
  69. Use wp_update_user to update custom column in wp_users table
  70. Are User Levels Still Currently Used?
  71. Max no of simultaneous active sessions for a single user
  72. WPML Default Language User Meta [closed]
  73. Display users in order by an “order” custom meta field
  74. Search Users base on meta_value & meta_key
  75. mysql query two database tables, users and usermeta and sort by custom meta int value
  76. Rest API code to get ID of current user not working: get_current_user_id() gives 0
  77. When I try to login in wordpress it is showing “USER Doesn’t Exists”
  78. Updating wp_user_level on user update
  79. Redirect subscribers to last viewed page after log-in
  80. User Meta Data in a Sortable Table
  81. get_user_meta an ID for multiple functions
  82. wordpress disable login for unverified user
  83. Reset Password policy
  84. Rewrite Rules and Login Issue
  85. How can I attach a user to another user with user meta
  86. Column Sorting Code on users.php
  87. Is possible to allow user to login with different role?
  88. Creating user without username and password
  89. List users by meta_key and meta_value
  90. Is this code true or not
  91. Use WordPress Login for a non-wordpress site
  92. users and usermeta table
  93. WordPress Login Customization for External Authentication
  94. WordPress SQL Issue not returning correct reselts
  95. User description only displayed for logged user
  96. The Simple and Correct Way to Add User Meta
  97. Does wordpress support natively the concept of logging-in users? (not admins, but users of the website)
  98. How to pull all the contributer users records and order by Designation (which is users meta data)?
  99. cannot get user_registered date from get_user_meta
  100. Is there any action /filter hook I can use to disable login for some user role?
Categories users Tags login, post-status, user-meta, users
WordPress not registering Theme Customization Section
What is minimum time interval for which a cron be scheduled?

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