Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9077251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:17:54+00:00 2026-06-16T19:17:54+00:00

Using cake acl I am trying to set permissions for logged in users. I

  • 0

Using cake acl I am trying to set permissions for logged in users. I have this in the login function:

if ($user = $this->Auth->user()) {
    CakeLog::write('debug', 'this->Auth->user');
    //debug($user['User']);
    $userGroup = $this->User->Group->findById($user['User']['group_id']);
    $aro = $this->Acl->Aro->find('first', array(
        'conditions' => array(
            'Aro.model' => 'Group',
            'Aro.foreign_key' => $this->_user['User']['group_id'],  
        ),
    ));
    $acos = $this->Acl->Aco->children();
    foreach ($acos as $aco) {
    $permission = $this->Acl->Aro->Permission->find('first', array(
        'conditions' => array(
            'Permission.aro_id' => $aro['Aro']['id'],
            'Permission.aco_id' => $aco['Aco']['id'],
        ),
    ));
    if (isset($permission['Permission']['id'])) {
        if ($permission['Permission']['_create'] == 1 ||
            $permission['Permission']['_read'] == 1 ||
            $permission['Permission']['_update'] == 1 ||
            $permission['Permission']['_delete'] == 1) {
                $this->Session->write(
                    'Auth.Permissions.' . $permission['Aco']['alias'], true
                );
                if (!empty($permission['Aco']['parent_id'])) {
                    $parentAco = $this->Acl->Aco->find('first', array(
                        'conditions' => array(
                            'id' => $permission['Aco']['parent_id']
                        )
                    ));
                    $this->Session->write(
                        'Auth.Permissions.' . $permission['Aco']['alias']
                        . '.' . $parentAco['Aco']['alias'], true
                    );
                }
            }
        }
    }
}

I am getting this error:

Undefined property: UsersController::$_user [APP\controllers\users_controller.php, line 82]

I can change out ‘$this->_user[‘User’][‘group_id’]’ with ‘$this->_user[‘User’][‘group_id’]’, would that be correct. If not what should I set public $_user = ?

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:17:55+00:00Added an answer on June 16, 2026 at 7:17 pm

    I replaced _user with $user and it seems to be working.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am confused about how to set this up using Cake's conventions. I have
I'm using ACL and Auth in my application. If a logged-out user loads an
I have cake php app and I am using translating function <?php __('msg'); ?>
i am using cakephp and creating this condition: $conditions = array(Userword.levelid=>0, Userword.userid=>$this->Auth->user('UserId'),date(Userword.date)=>DATE_SUB(CURDATE(),INTERVAL 0 DAY));
I am creating a form using Cake.In the form there is a $this->Form->button($i); element.
You can't have your cake and eat it too, apparently. I'm currently using the
I am using the Cake's inbuilt auth module . Everything is working fine on
Using CakePHP 1.3, I have the following layout: /srv/www/_cakephp13/ /app/ /cake/ /plugins/ /vendors/ etc...
Im trying to make a front page for a website using cake. I want
Using cake 2.1, I'm trying to get a list of json records via ajax.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.