I want to return the Login Error Message even user key-in their privileges correctly. In other words, to terminate the login and show the error message.
When we key-in wrong passwords, wordpress shows:
There was an error authenticating your details.
ERROR: The password you entered for the username admin is incorrect. Lost your password?
.. on the login page. This is because of WP_Error
Object is returned.
So my curious question is:
- How to get/generate this
WP_Error
Object on my own, to return back? Is it Array?
You need to hook into the authenticate wordpress hook. Then return a new WP_Error object to generate an error message and redirect back to the login page. Here is an example.