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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T12:39:19+00:00 2026-06-09T12:39:19+00:00

This is my first question here and I beleive the question is not exists

  • 0

This is my first question here and I beleive the question is not exists already 🙂 I searched but without succes.

Ok, I have a next problem.
I need some idea how to do a users permissions in admin panel.
I want to have a super admin, admin and operator.
Anyone of this wiil have different privileges.
Super admin wiil have all privileges, admin some and operators some but not all will have the same privileges.
I need a back-end logic for this.
How to do that without many if statements so my code looks nice?
I use a Smarty template engine and oop php writen by my own.
I wiil assign with Smarty privilege but what next?
Can anyone give me idea or some example code?

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-09T12:39:20+00:00Added an answer on June 9, 2026 at 12:39 pm

    Using MVC this is a relatively simple task. Create the different roles in a table called permissions and then another table called user_permissions which connects the user_id to the permission_id. Then create a function, maybe in a class called user called has_role(). That function accepts two arguments: permission alias and eventually a user id.

    If you want to avoid calling functions in the view, you can in your controller save different variables, which are passed to the view, such as:

    $isAdmin = $user->has_role('admin');
    $isOperator = $user->has_role('operator');
    

    If you’re only displaying some content to admins, you could do something like this in your views:

    <?php if($isAdmin): ?>
    
    <p>Admin only content</p>
    
    <?php endif; ?>
    

    However, if you’re having admin-only pages, simply putting

    if(! $this->user->has_role('role')) {
      header("Location: /index.php");
      die();
    }
    

    will do the trick. All of this is of course doable without the MVC-part, it however becomes way cleaner with it.

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

Sidebar

Related Questions

Well this is not the first time im asking these question here but I
this is my first question here :) I know that I should not check
this is my first question.. so, here we go. i have a site, 100%
Sorry, this's my first time to ask a question here. So, I don't have
First time poster here but definitely not a first time reader. My question is
First a caveat: I posted this question here on SuperUser, but it is clearly
My first question here, hopefully I'm not doing it wrong. My problem is that
Quick question. I have been Googling this all morning, but it's either not there,
this is my first question here so be gentle ! recently i try to
This is my first question here so try to make my best so you

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.