【发布时间】:2023-03-15 07:20:01
【问题描述】:
我需要一个功能来隐藏 Perfex CRM for User Roles 的某些部分。示例:折扣区。
我尝试使用此代码:
function hide_fields_nonusers()
{
if ($role != '4') {
<style type="text/css">
#sconto {
display: none !important;
}
#discount_area {display: none !important;}
</style>
}
但没有任何效果,它为每个人隐藏了这部分,包括管理员。
编辑
这个正在工作,但只是为了通过 ID 获取员工角色。
/**
* Get employee role by id
* @param mixed $id Optional role id
* @return mixed array if not id passed else object
*/
public function get($id = '')
{
if (is_numeric($id)) {
$role = $this->app_object_cache->get('role-' . $id);
if ($role) {
return $role;
}
$this->db->where('roleid', $id);
$role = $this->db->get(db_prefix() . 'roles')->row();
$role->permissions = !empty($role->permissions) ? unserialize($role->permissions) : [];
$this->app_object_cache->add('role-' . $id, $role);
return $role;
}
return $this->db->get(db_prefix() . 'roles')->result_array();
}
【问题讨论】:
-
我不确定这是您的客户端代码还是服务器端代码,并且它不会使用 php 或 javascript 编译,因此您可能只是将其转储到浏览器中,然后尝试解释它。你的 JavaScript 控制台有错误吗?
-
不:/没有错误。它称为 STYLE,但适用于所有人,而不仅仅是角色。
-
你在哪里调用那个函数?
标签: javascript php codeigniter