How to password protect just an action in a controller

I am building a site where all pages a Public, except for one Action (Create) in a Controller.

Is there a simply way that some one can think of it?

A very simple Hard Coded UID/PW will solve the purpose. Thinking that Filters will help. Let me know if some one has already done this.


Did You thing to use accessRules as docs write?

You mean something like this?

public function actionRestricted()


    if (Yii::ap()->user->isGuest)


    // Restricted code here


 public function accessRules()


        return array(







    public function filters()


        return array(




Long gone but I am revisiting this today.

I am using…ord-protect.php for his purpose. I have no need of user table, a hard coded user and password is fine because it basically just protect only the action in the entire site, i.e., ‘create page’.

Any alternative/suggestion to do the Yii will be appreciated, or if any one has already done this please let me know.

Never mind, I just used the session to achieve that

Is really a simple stuff to do it, just use access rules as said dimis283 or a custom solution as as said Mike, it doesn’t worth to implement anything.