How To Show A Custom Error Message On Invalid Login User

I have set some custom validation for login the user, i.e. once a user create an account then that account will be confirmed by the administrator of the site, for that purpose I am using is_confirmed (ENUM) type field. and I have set its validation on login action and a user can’t login if its not yet confirmed, but I have set a simple text message like “You are not yet confirmed” and this message is displayed at the top of the page.

Now I want to show that message in form, just like when we enter an invalid password then it shows the message that your password is inavlid etc.

So how can I show my message in the login form below the text field boxes.

Thanks in advance.

In your model create variable,


public $my_error_message;

In form.php


<?php echo $form->error($model,'my_error_message'); ?>

when you validate in your mode add this


 $this->addError('my_error_message','You are not yet confirmed');