Please help me explain 9 line of code in Yii_user extension

This is the function plugin for RegistrationController of Yii_user module (

	public function actions()


		return (isset($_POST['ajax']) && $_POST['ajax']==='registration-form')?array():array(







I can understand most of the part, but couldn’t figure the following question:

why they want to attach the capatcha action when it’s not a ajax request, and don’t want to attach capatcha action when it’s an ajax request?


I think it’s because the captcha code may change after it’s validation.

It may remain the same for a few times, but it will change at last when you continue trying to be validated. So the author of Yii-user wants the captcha to be validated only one time at the last moment of the registration.


Sorry, the description above was not correct.

The validation of the captcha is performed in every ajax call.

By default, the captcha will remain the same for 3 times and will be changed for the 4th time.

So the author doesn’t want the captcha to be changed in ajax actions.


why you mention validation?

Oops! I was wrong. Not the validation, but the creation of capthca image in the ajax action.

About the captcha image duration, please see this article and the link to a reference in it.

To sum up, by default the same captcha image will be repeated 3 times and will be changed to a new one for the 4th time.

And a long form like the registration will require more than 3 ajax actions before it is completed. And you will not like the captcha image to be changed while you are still filling the form.