In order to execute a specific code after a Yii controller method (action) called you can proceed by using the following method: afterAction
You cannot specify the action or not
here’s an example:
1 2 3 |
public function afterAction() { // execute your code here } |
with the same principle you can call the method: beforeAction
do not forget however to return true before end of the method
1 2 3 4 |
public function beforeAction() { // execute your code here return true; } |
![Share on Facebook Facebook](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/facebook.png)
![Share on Twitter twitter](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/twitter.png)
![Share on Reddit reddit](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/reddit.png)
![Pin it with Pinterest pinterest](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/pinterest.png)
![Share on Linkedin linkedin](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/linkedin.png)
![Share by email mail](https://ictknowledge.net/wp-content/plugins/social-media-feather/synved-social/image/social/regular/96x96/mail.png)