douweng7083 2018-05-02 15:31
浏览 44
已采纳

PHP IF标签Wordpress

I currently have below, its showing that this template can only be accessed by the inspector role. I want to add multi role to this. What would be the best option.

if ( !current_user_can ('inspector')) {
    get_template_part('error');
    exit(0);
}
  • 写回答

1条回答 默认 最新

  • dsgtew3241 2018-05-02 15:36
    关注

    I'm not entirely sure that I understand the question, but this will show the error template if the user is not an inspector or admin. You can chain as many && together as you need for each role.

    if ( !current_user_can ('inspector') && !current_user_can('admin')) {
        get_template_part('error');
        exit(0);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 很想要一个很好的答案或提示
  • ¥15 扫描项目中发现AndroidOS.Agent、Android/SmsThief.LI!tr
  • ¥15 怀疑手机被监控,请问怎么解决和防止
  • ¥15 Qt下使用tcp获取数据的详细操作
  • ¥15 idea右下角设置编码是灰色的
  • ¥15 全志H618ROM新增分区
  • ¥15 在grasshopper里DrawViewportWires更改预览后,禁用电池仍然显示
  • ¥15 NAO机器人的录音程序保存问题
  • ¥15 C#读写EXCEL文件,不同编译
  • ¥15 MapReduce结果输出到HBase,一直连接不上MySQL