Reputation: 441
I am a trainee now. I am continue doing a a project left by last semester trainee. I found out he did a code as below :
$auth = $this->Auth->User();
if(!empty($auth)) {
$auth['User']['is_admin'] = $this->inGroup('admin');
Can anyone teach me how to avoid this error ? Thank you.
Upvotes: 1
Views: 936
Reputation: 3939
the error indicates that you parse string into array expected function
eg.
$this->inGroup(array('admin')); //check out its function definition for valid parameters.
Upvotes: 1
Reputation: 2286
You can check if $auth
is an array.
if(!empty($auth) && is_array($auth) && isset($auth['User'])) {
Upvotes: 1