Extract the CurrentUserLevelName()

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
eayvl
User
Posts: 315

Extract the CurrentUserLevelName()

Post 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.


mobhar
User
Posts: 11660

Post by mobhar »

Try:

$MyResult = ew_Execute("UPDATE f_ejecutivo SET fe_userlevel = '" . CurrentUserLevelName() ."' WHERE fe_id=".$rsnew["fe_id"]);


eayvl
User
Posts: 315

Post 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.


Chris
User
Posts: 162

Post by Chris »

User Level is stored numerically, so use CurrentUserLevel() to get the equivalent ID for the Current User Level.


eayvl
User
Posts: 315

Post 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.


Chris
User
Posts: 162

Post 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"]);


eayvl
User
Posts: 315

Post by eayvl »

Thank you very much for the solution, Chris.


mobhar
User
Posts: 11660

Post 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"]);


Post Reply