I create local administrators on the systems I develop, I do not give them access to Builder. I setup many screens for them to do what the ordinary user cant/shouldn't do, i.e add users, assign users to roles etc..
I want to limit what roles these Administrators can assign, at the moment once I give them the Roles field there is no way of filtering it so some Roles are not visible, its either all or nothing.
I would like to be able to filter the Roles field.
I am looking for a similar User Role data field capability...
The way I intend to use this role type is to enable say the Super User (ie. Portal owner to assign a User Admin role to a (level 1) business service provider. This User Admin role would then be able to create and manage their own level 2 normal users. (think of a 2 level tree structure). The User Admin role however cannot and must not be able to assign a Super User role to itself or to any of its normal Users.
There will ever be only 1 Super User role (i.e. the Portal owner),
There can be 1 or more User Admin roles (eg. individual shop owners using the Portal),
Following on, each of the User Admin (show owners) can create or manage their own shop User logins of which there can be multiple User logins belong to a specific shop...
I have been using your snippet of code to filter User Roles for 18 months now and it has worked just great, thanks again.
I was wondering if you had refined it at all, I have just found out that if a user searches for a Role they can find it even though it has been hidden from view? Also it would be so much better if I could define what Roles to view as apposed to what Roles to hide.
If you have done anything more with this I would be very interested.
Thank you for the topic. It was very helpful. I had to build a similar code for more than one access roles (similar teams) but I had to hide the access from a team to another.
Blow is my code.
//Team A & Roles field for edit user role
$(document).on(‘mousedown keyup’,
‘#view_37_field_10_chzn’ +
‘, #view_107_field_10_chzn’ +
‘, view_134_field_10_chzn’
, function () {
console.log (Knack.getUserAttributes().roles);
if (Knack.getUserRoles().includes("object_17"))
{
if (!Knack.getUserRoles().includes("object_18"))
$("ul.chzn-results li:contains('Super user - Team B')").remove();
if (!Knack.getUserRoles().includes("object_19"))
$("ul.chzn-results li:contains('Super user - Team C')").remove();
$("ul.chzn-results li:contains('Admin')").remove();
console.log ('2');
}
console.log ('3');
}
);
//Team B & Roles field for edit user role
$(document).on(‘mousedown keyup’,
‘#view_37_field_10_chzn’ +
‘, #view_107_field_10_chzn’ +
‘, view_134_field_10_chzn’
, function () {
console.log (Knack.getUserAttributes().roles);
if (Knack.getUserRoles().includes("object_18"))
{
if (!Knack.getUserRoles().includes("object_17"))
$("ul.chzn-results li:contains('Super user - Team A')").remove();
if (!Knack.getUserRoles().includes("object_19"))
$("ul.chzn-results li:contains('Super user - Team C')").remove();
$("ul.chzn-results li:contains('Admin')").remove();
console.log ('2');
}
console.log ('3');
}
);
//Team C & Roles field for edit user role
$(document).on(‘mousedown keyup’,
‘#view_37_field_10_chzn’ +
‘, #view_107_field_10_chzn’ +
‘, view_134_field_10_chzn’
, function () {
console.log (Knack.getUserAttributes().roles);
if (Knack.getUserRoles().includes("object_19"))
{
if (!Knack.getUserRoles().includes("object_18"))
$("ul.chzn-results li:contains('Super user - Team B')").remove();
if (!Knack.getUserRoles().includes("object_17"))
$("ul.chzn-results li:contains('Super user - Team A')").remove();
$("ul.chzn-results li:contains('Admin')").remove();
console.log ('2');
}
console.log ('3');
}