To avoid the direct access overide the CContoller::beforeAction() in UserController.
UserController.php
public function beforeAction($action)
{
if($action->id=='register')
{
throw new CHttpException(" :you are not having any direct access to Registration.");
}
return true;
}
Then in PaypalController, we can do something.
public function actionPaysuccess()
{
if(something is true) // that is on successfull payment...
{
$model=new User('register');
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->save())
//do something here.
}
$this->renderPartial("//user/register",array('model'=>$model),false,true); //bring out the registration form.
}
}
This way we made the action user/register totally non existing.
This is almost equivalent to removing user/register.
If you want still use the user/register, then we can do the following.
1.create a folder restricted inside protected/controllers.
2.Copy the UserController.php and place it inside the restriced folder.
3.Then remove the UserController::beforeAction() from UserController.php residing inside the restricted folder.
Then in PaypalController, we can do the following.
public function actionPaysuccess()
{
if(something is true) // that is on successfull payment...
{
Yii::app()->controllerPath=Yii::app()->controllerPath."/restricted";//accessing the UserController.php in restricted folder.
$this->forward("user/register");//forward... do not redirect.
}
}
thanks for your answer. it has definitely set the ball rolling for me.
I am stuck at one small issue.
With renderpartial i am being able to display the registration form on the payment/confirm page.
However the default <form action=""> still remains as ‘payment/confirm’ where as it should be ‘user/register’ for the form to work.
In my case the registration view is located in a module.user.view.registration
what do i add as for the action in my registration form ?
$form=$this->beginWidget('UActiveForm', array(
'id'=>'registration-form',
'action'=> '[b]? -- what do i add here ?[/b]',
'enableAjaxValidation'=>true,
'disableAjaxValidationAttributes'=>array('RegistrationForm_verifyCode'),
'clientOptions'=>array(
'validateOnSubmit'=>true,
),
for form action="", I added:
'action'=>array('user/registration'),
but it doesnt solve the purpose.
Just in case it matters, the register button is coded as:
Bring all the logic from ‘user/register’ to ‘paypal/pauSuccess’.
public function actionPaysuccess()
{
if(something is true) // that is on successfull payment...
{
$model=new User('register');
if(isset($_POST['User']))
{
$model->attributes=$_POST['User'];
if($model->save())
//Bring all the logic residing in "user/register" here.
}
$this->renderPartial("//user/register",array('model'=>$model),false,true); //bring out the registration form.
}
}