Role management Codeigniter

0

How do I show in a select that I can select only one user if this is a different user to the administrator, because only can send messages to several users is the one with administrator profile

this is my view

 <select name="users[]" id="users" multiple="multiple">
                  </select>

Could you use a php query to validate the role?

thanks

    
asked by Edison Sarmiento 04.04.2018 в 17:52
source

1 answer

1

You can obtain information from the user with the session or make some query to obtain the role and depending on the role you have add or delete the attribute of multiple to your select. In this example I am assuming that the role is in the session variable "role" in your case I do not know how you are handling it:

<?php

  $rol = $this->session->userdata('rol');
  if ($rol == 'administrador') {
       $selMultiple = 'multiple="multiple"';
  } else {
       $selMultiple = '';
  }
?>

   <select name="users[]" id="users" <?= $selMultiple; ?> />
   </select>
    
answered by 04.04.2018 в 18:32