Delete Menu Item Based on User Group

hello,

can someone advise me if my code and step below are correct:

I want to delete menu item based on users group.

I have 3 groups:

  1. administrator
  2. seller
  3. buyer

The security module is automatically generated by SC.

FIRST STEP: I put this code below after “$rs->Close();” line in my Login application in the OnValidateSuccess Event:

sc_lookup(rs, “SELECT sec_groups.description
FROM sec_users_groups, sec_groups
WHERE sec_users_groups.login = '”.{login}."’");
[user_group] = {rs[0][0]};

SECOND STEP: I set usr_group to be OUT type in the Global Variable section of my login application.

THIRD STEP: I created a conditional statement in LOAD Event in my Menu Application, here is the statement.

if([user_group]==‘administrator’){
sc_menu_delete(item_1, item2);
}

elseif ([usr_login] ==‘seller’)
{
sc_menu_delete (item_3, item_4);
}
else ([usr_login] ==‘buyer’)
{
sc_menu_delete (item_5);
}

This conditional statement works well for administrator group when access menu item BUT It did not work for seller and buyer group.

Please suggest me what is wrong in my codes and steps above.

Thank You
Subhan

Not quite understanding, assigning application security to groups will make the menu items invisible anyway.
How are you testing your security?

Kevin

Kevin,
Thank so much for your enlightening. I am a new user of SC. Now I understand. It is very easy to enable and disable access to certain applications based on user groups. We can do it right inside the application with clicks, no needs with custom code like what I made above.

Again thank you so much Kevin.

Subhan.

elseif ([usr_login] ==‘seller’)
{
sc_menu_delete (item_3, item_4);
}
else ([usr_login] ==‘buyer’)
{

You must change;

[usr_login] --------> [user_group]