Skip to content
Advertisement

HOW CAN I HIDE A FORM BASED ON USER ROLE OR PRIVILEGE PHP [closed]

Please how can I hide a form or input field based on the user role or privilege using PHP. is it possible to do that using sessions and if so, how?

Advertisement

Answer

function return_html(){
$role = $_SESSION['role'];
$approved_role=[1,2];
  if(in_array($role ,$approved_role)){
   echo '<button>Add New</button>';
   }

}

use this function in your form it will be global and you can also defined permission in your db and fetch it inside the function and then make the condition.

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement