I gave contributor the capability to add users, delete user, list user. When contributer logged in, all user (users created by contributor and created by administrator)lists but I dont wan’t to display all users when contributor is logged in. When contributer is logged in, users crated by contributer should lists only and other users (created by administrator)should remove from the user list.
below is my attempt to achieve the goal but it is not working
I give body a classname contributor”
want to show rows with class “admin2”
users created by contributer gets classname = admin2
$(“body.contributor.users-php table.users tr:not(.admin2”).remove();
please let me know what’s wrong with this code
you should avoid this code.
Instead, I will suggest that you check current user capability on user_register action and if the user is logged in, set a flag for the newly created user based on the logged user’s role.
After that, you can hook to ‘pre_get_users’ and exclude based on the meta.
You must be logged in to reply to this topic.