This topic is locked
[SOLVED]

 How to get if the logged user belongs to <admin> Group

11/29/2011 11:01:47 AM
PHPRunner General questions
M
matteofaini author

Hi everyone from Matteo.
I have to write a "LIST PAGE - After record processed" Event that considers if the logged user belong to <admin> group or not. This condition has to work with another condition, based on date-time (the field "date-time").
Something like this:
if (($data["date-time"] > $data["today"]) AND (logged-user-doesn't-belong-to-admin-group))

{

$record["edit_link"] = false;

}
I can't use $_SESSION["AccessLevel"], because this variable only returns "Guest" or "User".
Is there a way to get this very useful information?

Thanks.
Matteo.

C
cgphp 11/29/2011
global $conn;
$strSQL = "SELECT GroupID FROM ugmembers WHERE UserName ='".$_SESSION["UserID"]."' LIMIT 1";

$rs = db_query($strSQL,$conn);

$record=db_fetch_array($rs);
if (($data["date-time"] > $data["today"]) AND $record['GroupID'] != -1)

{

$record["edit_link"] = false;

}
Sergey Kornilov admin 11/29/2011

$_SESSION["AccessLevel"] is the right variable to check. You can also check $_SESSION["GroupID"].

More info: http://xlinesoft.com/phprunner/docs/phprunner_session_variables.htm

M
matteofaini author 11/29/2011

With this little modification it works great... thanks to Cristian Gilè!
global $conn;
$strSQL = "SELECT GroupID FROM ugmembers WHERE UserName ='".$_SESSION["UserID"]."' LIMIT 1";

$rs = db_query($strSQL,$conn);

$record2=db_fetch_array($rs);
if (($data["date-time"] > $data["today"]) AND $record2['GroupID'] != -1)

{

$record["edit_link"] = false;

}