customize login error message I'm using Omega's sub-theme 'creativpink' and ajax_register module. 

When user enters wrong user name or wrong password I want show *'The password entered is wrong. Please retry.' instead of Drupal's default error 'Sorry, unrecognized username or password. Have you forgotten your password?'. 

I've tried with following code in my sub-theme's template.php file :

function _custom_validation(&$form, &$form_state){
  $query = db_select('users', 'u');
  $query->fields('u', array('name'));
  $query->condition('u.name', $form_state['values']['name'], '=');
  $result = $query->execute();
  $name = $result->fetchField();
  if(empty($name)){
    form_set_error('user_name', t('The password entered is wrong. Please retry.'));
  }
}

After saving file I entered wrong user name and password. The error message showed both default text and my custom text.


Sorry, unrecognized username or password. Have you forgotten your password?
The password entered is wrong. Please retry.


But I want to show only my custom error message. How to do this?
You can use function form_get_errors and function form_clear_error

function _custom_validation($form,$form_state){
  $errors = form_get_errors();
  if(!empty($errors)){
    $string_error = $errors['name'];
    if (strpos($string_error, 'unrecognized username or password') !== FALSE) {
      form_clear_error();
      form_set_error('name','The password entered is wrong. Please retry.');
    }
  }
}