Page 1 of 1
Extract the CurrentUserLevelName()
Posted: Mon Nov 20, 2017 2:56 pm
by eayvl
Hi, how can i extract the user level name.
Failed to execute SQL. Error: FUNCTION 2017_kiosco.CurrentUserLevelName does not exist
$MyResult = ew_Execute("UPDATE f_ejecutivo SET fe_userlevel=CurrentUserLevelName() WHERE fe_id=".$rsnew["fe_id"]);
Failed to execute SQL. Error: FUNCTION 2017_kiosco.CurrentUserLevelsName does not exist
$MyResult = ew_Execute("UPDATE f_ejecutivo SET fe_userlevel=CurrentUserLevelsName() WHERE fe_id=".$rsnew["fe_id"]);
only this way it works
$MyResult = ew_Execute("UPDATE f_ejecutivo SET fe_userlevel='Manager' WHERE fe_id=".$rsnew["fe_id"]);
Thank.
Re: Extract the CurrentUserLevelName()
Posted: Mon Nov 20, 2017 3:41 pm
by mobhar
Try:
$MyResult = ew_Execute("UPDATE f_ejecutivo SET fe_userlevel = '" . CurrentUserLevelName() ."' WHERE fe_id=".$rsnew["fe_id"]);
Re: Extract the CurrentUserLevelName()
Posted: Tue Nov 21, 2017 12:00 am
by eayvl
mobhar wrote:
Try:
$MyResult = ew_Execute("UPDATE f_ejecutivo SET fe_userlevel = '" . CurrentUserLevelName() ."' WHERE fe_id=".$rsnew["fe_id"]);
Fatal error: Uncaught Error: Call to undefined function CurrentUserLevelName() in C:\xampp\htdocs\... f_ejecutivoinfo.php on line 1204
if, i use CurrentUserName() works very well; but I need to extract current user level name.
Thank mobhar.
Re: Extract the CurrentUserLevelName()
Posted: Tue Nov 21, 2017 1:56 am
by Chris
User Level is stored numerically, so use CurrentUserLevel() to get the equivalent ID for the Current User Level.
Re: Extract the CurrentUserLevelName()
Posted: Tue Nov 21, 2017 4:21 am
by eayvl
Chris wrote:
User Level is stored numerically, so use CurrentUserLevel() to get the equivalent ID for the Current User Level.
I need it to be visible (Default, Sales, Manager etc). I understand that I can not use '". CurrentUserLevelName() ." for to update the field.
Re: Extract the CurrentUserLevelName()
Posted: Tue Nov 21, 2017 5:38 am
by Chris
You could pull the level name in a query prior to updating, i.e.
$uln = ew_ExecuteScalar("SELECT userlevelname FROM userlevels WHERE userlevelid = " . CurrentUserLevel() );
// and use it in your function
$MyResult = ew_Execute("UPDATE f_ejecutivo SET fe_userlevel='".$uln."' WHERE fe_id=".$rsnew["fe_id"]);
Re: Extract the CurrentUserLevelName()
Posted: Tue Nov 21, 2017 6:32 am
by eayvl
Thank you very much for the solution, Chris.
Re: Extract the CurrentUserLevelName()
Posted: Tue Nov 21, 2017 10:23 am
by mobhar
I just realized that CurrentUserLevelName() belongs to the Security object. It's not a global function just like CurrentUserName(). So you should be able to simply use this following code:
$MyResult = ew_Execute("UPDATE f_ejecutivo SET fe_userlevel = '" . Security()->CurrentUserLevelName() ."' WHERE fe_id=".$rsnew["fe_id"]);