Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?
share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

How to get/generate this WP_Error Object on my own, to return back?

$error = new WP_Error;

It is fairly well documented in the Codex.

Once you instantiate the object there are methods for adding errors and for retrieving them, and functions like is_wp_error to check a variable to see if it is an error object or not.

share|improve this answer
    
Wow, like this?? Its cool!! $user = new WP_Error( 'incorrect_password', sprintf( __( '<strong>ERROR</strong>: The password you entered for the username <strong>%1$s</strong> is incorrect. <a href="%2$s" title="Password Lost and Found">Lost your password</a>?' ), $username, wp_lostpassword_url() ) ); –  シリウス May 14 '13 at 4:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.