Answer the question
In order to leave comments, you need to log in
YII2 How to show delete and change buttons only for post author?
The standard view generated by GII has delete and change buttons.
How can I make them visible only to the author of the post?
the controller has a check for the role of the author when switching to editing or deleting:
if (!Yii::$app->user->can('updateOwnPost', ['post'=>$model])){
throw new ForbiddenHttpException("You must be Owner of this Pedigree");
}
Answer the question
In order to leave comments, you need to log in
'visibleButtons' = [
'update' => Yii::$app->user->can('updateOwnPost')
'delete' => Yii::$app->user->can('updateOwnPost')
]
wrap the buttons exactly the same way, what stopped you from trying it?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question