我想禁用一个按钮使用角色管理员,这是我的代码。
<div class="footer-section">
<?php if($this->user->role !== 'admin' && $this->user->role !== 'worker') ?>
<button type="button" class="btn btn-red col-md-6 flat-box-btn" data-toggle="modal" data-target="#AddSale"><h5 class="text-bold"><?=label('PAY');?></h5></button>
</div>不能用,我用sales作为用户,按钮还在显示,谁能帮帮忙吗?
发布于 2018-01-19 23:33:48
如果只想向具有admin或worker角色的用户显示该按钮,请将条件更改为:
<?php if($this->user->role == 'admin' || $this->user->role == 'worker') {
echo "<button type='button' class='btn btn-red col-md-6 flat-box-btn' data-
toggle='modal' data-target='#AddSale'>
<h5 class='text-bold'>".label('PAY')."</h5>
</button>";
}?>发布于 2018-01-19 23:54:13
您需要在if语句中echo该按钮。
<div class="footer-section">
<?php
if($this->user->role !== 'admin' && $this->user->role !== 'worker') {
echo '<button type="button" class="btn btn-red col-md-6 flat-box-btn" data-toggle="modal" data-target="#AddSale"><h5 class="text-bold">' . label('PAY') . '</h5></button>'
}
?>
</div>这仅在角色不是admin也不是worker时呈现按钮。
发布于 2018-01-19 23:55:25
<div class="footer-section">
<?php if($this->user->role !== 'admin' && $this->user->role !== 'worker')
echo '<button type="button" class="btn btn-red col-md-6 flat-box-btn" data-toggle="modal" data-target="#AddSale"><h5 class="text-bold">'.label("PAY").'</h5></button>';?>
</div>https://stackoverflow.com/questions/48344088
复制相似问题