I have custom login form and i used wp_signon() to authenticate. However, i wanted to run an additional check for usermeta and if the user has account_status === pending, throw an error or or prevent them from getting logged in. How do i do that? I can’t seem to find a filter
Leave a Reply
You must be logged in to post a comment.
You could do this with a low-priority authenticate filter. I’m surprised there aren’t more appropriate hooks in the login process, but I can’t see one. (There is already an example of a filter like this though: wp_authenticate_spam_check.)
If the value the filter is given is a user, that means a previous filter has accepted the username & password. We can then perform our check and then either return the user if good or an error if not:
I have not tested this, but the general pattern should work even if this code doesn’t. This runs before the cookie is created etc.