Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Determining user access level.

edited October 2010 in Vanilla 2.0 - 2.8
Hi guys,

Really enjoying looking at the great work in this forum.

I'm writing a simple "links of interest" panel where if the current user is an admin the view will enable a simple CRUD interface for links.

I need to be able to determine the userID in order to query whether or not a user is an admin. The structure below would suggest that I cannot access the userID.

Whats the methodology for this? I know this is probably a noobie question.


V.

[Database] => Gdn_Database Object
(
[ClassName] => Gdn_Database
[_CurrentResultSet:Gdn_Database:private] => Gdn_DataSet Object
(
[Connection] => PDO Object
(
)

[_Cursor:Gdn_DataSet:private] => -1
[_DatasetType:protected] => object
[_EOF:protected] =>
[_PDOStatement:Gdn_DataSet:private] =>
[_Result:protected] => Array
(
[0] => stdClass Object
(
[UserID] => 1

Comments

  • Of course.

    Being an instance of gdn, that gives me access to the Session/User attribute. I should of PHPdoc'd this before asking stupid questions.

    Sorry guys

    class myPluginClass extends Gdn_Module{

    public function getAdminExample(){

    $session = gdn::Session();
    $userID = $session->User->UserID;
    $isAdmin = $session->User->Admin; //will be true if the current user is an admin

    }

    }

Sign In or Register to comment.