I'm trying to force the WordPress login function to fail on certain conditions. Basically, we have a situation where we have users that have allowed their accounts to expire in our membership environment. The idea is that if they try to login, it just fails their login because they won't be able to access anything anyhow so I figure we just let them know with a custom login_errors
message.
The issue is that the user has to have a login error in order to make this happen (meaning they have to use an incorrect username/password combination). In this case, they would still have logins but they just don't have a valid membership to interact with the content on the site.
I'm intercepting the process using the wp_authenticate
hook and I'm able to successfully grab the information from the user logging in but I can't seem to force it throw an error. If I return false
or return new WP_Error()
it doesn't work. If I change the credentials in the flow, that doesn't seem to matter either.
Any ideas on how to force it to fail the login and redirect to the login page with the new error message?
wp_login_errors
filter for this?