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 6115405
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T15:05:14+00:00 2026-05-23T15:05:14+00:00

Please forgive me, I am still fairly new to cakephp and in the process

  • 0

Please forgive me, I am still fairly new to cakephp and in the process of reviving my redundant PhP skills.

I have searched all over the “interweb” for the answer, sadly to no avail.

Here is the scenario:

I have 2 tables – 1 being Users the other Groups ( for permissions).

Users table – pretty standard plus some additional profile info.

Groups table – holds Administrators, Super Users, Auth Users and Unauth Users.

The Users table is being used for authentication and profiles (other users can browse user profiles). Now with this in mind, I cannot work out how to filter out which users get rendered into the index view based on which group the users (not the the currently logged user) belong.

For example, The admin and Super user accounts profiles are being rendered and belongs to the “Administrators” and “Super users” groups respectively along with all the other Users. However all I want end users (Auth Users) to be able to see are other user profiles which are part of the Auth Users group.

So any and all help would be appreciated for both saving the remainder of my hair and finding a resolve to this problem I have.

Ok so here is what I did which is working like a charm. Configured the paginate variable to look like this:

var $paginate = array(
            'fields' => array(
                    'User.img_file', 'User.given_name', 'User.family_name', 'Group.name', 'User.username', 'User.created'),
            'limit' => 10,
            'order' => array(
                'User.given_name' => 'asc'
            )
        );

Then for the in the index function (which I wanted) I added the following:

function index() {
                $this->User->recursive = 0;
                $this->paginate = array(   
                'conditions' => array(
                                  'group_id' => 3
                ));
                $users = $this->paginate('User');
                $this->set(compact('users'));
}

It’s working like I want it to, but if anything does look malformed, or this can be extended, please do post comments.

  • 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-05-23T15:05:14+00:00Added an answer on May 23, 2026 at 3:05 pm

    First off, take a look at this for information on using the built in authentication features of cakephp.

    ” I cannot work out how to filter out which users get rendered into the index view based on which group the users (not the the currently logged user) belong.”

    not 100% on what you mean by this, but if you mean you only want to see other users that are admins (and assuming you know that the admin_group_id == 1) then, what you kind of want is the following.

    $administrator_group_id = 1;
    
    $conditions = array(
      'group_id' => "{$administrator_group_id}"
    );
    
    $this->data = $this->User->findAll($conditions); 
    // note. automatically makes the result data available in the VIEW layer
    
    pr($this->data); // VARDUMP utility
    

    (ps. check this out for how to paginate this result data)

    “…all I want end users (Auth Users) to be able to see are other user profiles which are part of the Auth Users group”

    (assuming the auth stuff didn’t help you.)

    (if there are only 3 types of group types, and I can control them completely, then I would consider not using a group table, and using an enumeration. here are notes on how to do this in MySQL

    http://dev.mysql.com/doc/refman/5.0/en/enum.html

    or, you can just sort of hack it in PHP.

    eg.

    define('USER', 1);
    define('S_USER', 10);
    define('ADMIN', 100);
    

    $user = $this->User->findById($my_user_id); // or get from auth

    $conditions = array(
    “group_id <= ” => “{$user[‘User’][‘group_id’]}”
    );

    $this->data = $this->User->findAll($conditions);
    pr($this->data); // VARDUMP

    ( what I did was that you get the logged in user, and I made sure that the ADMIN had the highest level ID. SuperUsers had the 2nd, and Users the lowest. This query will return all users that are on the same level, or lower than their own level. group_id <= User.group_id)

    I hope I haven’t confused you too much. Just keep on experimenting with cake. It’s worth it!

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

Sidebar

Related Questions

I am still shiny new to XNA, so please forgive any stupid question and
I am new... to the site and to PHP in general. Please forgive my
Please forgive this rather basic question, but I'm very new to Java and still
Please forgive the ignorance, but I'm very new to PHP and I couldn't find
Greetings all and please forgive me if my question is too cheap. I have
Ok Guys please forgive my ignorance. I'm new to javascript so all help is
OK, I'm still quite new to Xcode/Cocoa etc, so please forgive me if this
Please forgive me if this is an obvious one. I have an unknown amount
Please forgive me if this is answered on SO somewhere already. I've searched, and
I'm still a relative newcomer to Zend Framework, so please forgive me if this

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.