简体   繁体   English

检查最终用户是否为管理员

[英]Check if the end user is admin

I've to check whether the end user is admin or not, I've done right (I hope) but it fails to check. 我必须检查最终用户是否是管理员,我做对了(我希望如此),但是它无法检查。 Here is what I'm using; 这是我正在使用的;

function checked_already($pid,$input)
{
    global $db;
    if ($mybb->user['usergroup'] != "4")
    {
        error_no_permission();
    }
    $query = $db->simple_select("users", "username", "uid='{$input}' OR username='{$input}'");
    $user = $db->fetch_array($query);

    if (!$user['username'])
    {
        echo "Nothing found!!";
        exit;
    }
}

But it fails to check if the end user is admin. 但是它无法检查最终用户是否为管理员。 :/ No error at all. :/完全没有错误。 What is missing here? 这里缺少什么?

You've not used $mybb in global. 您尚未在全局中使用$ mybb。 Try this; 尝试这个;

function checked_already($pid,$input)
{
    global $db, $mybb;
    if ($mybb->user['usergroup'] != "4")
    {
        error_no_permission();
    }
    $query = $db->simple_select("users", "username", "uid='{$input}' OR username='{$input}'");
    $user = $db->fetch_array($query);

    if (!$user['username'])
    {
        echo "Nothing found!!";
        exit;
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM