DISCUZ插件开发, 指定用户UID和用户组访问插件页面写法

2021-03-17 977 0条评论

用户UID

$haozidashuju = $_G['cache']['plugin']['haozi_xgdata'];
$uids = explode("\r\n", trim($haozidashuju['uids']));
if (!in_array($_G['uid'], $uids)) {
   showmessage('请登录之后再继续操作!', '', array(), array('login' => true));
}
include template('haozi_xgdata:xiguadata/index', 0, '/source/plugin/haozi_xgdata/template');

用户组

$yonghuzu = empty($haozidashuju['yonghuzu']) ? array() : unserialize($haozidashuju['yonghuzu']);

if (!in_array($_G['group']['groupid'], $yonghuzu)) {
      showmessage('请登录之后再继续操作!', '', array(), array('login' => true));
}

include template('haozi_xgdata:xiguadata/index', 0, '/source/plugin/haozi_xgdata/template');



用户组和用户同时限制写法:

$haoziuids = explode(",", trim($haozidashuju['haoziuids']));
$yonghuzu = empty($haozidashuju['yonghuzu']) ? array() : unserialize($haozidashuju['yonghuzu']);
 
 if (!in_array($_G['uid'], $haoziuids) && $haoziuids != 0 && !in_array($_G['group']['groupid'], $yonghuzu)) {
   showmessage($haozidashuju['xianzhitishi'], '', array(), array('login' => true));
  }


文章版权及转载声明

本文作者:符文浩 网址:http://blog.fuwenhao.com/post/370.html 发布于 2021-03-17
文章转载或复制请以超链接形式并注明出处。

发表评论

快捷回复:

评论列表 (暂无评论,977人围观)参与讨论

还没有评论,来说两句吧...

取消
微信二维码
微信二维码
支付宝二维码