Tagged: contributer, user table list, users
Hi therre,
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 = admin2function contributorr(){
if(current_user_can(‘contributor’)){?>
<script>
jQuery(function($){
$(“body.contributor.users-php table.users tr:not(.admin2”).remove();
});
</script>
<?php }
}
add_action(‘admin_init’,’contributorr’);please let me know what’s wrong with this code
Thak You!
Hi Waseem,
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.
Regards
BrajeshHi Waseem,
I am sorry, I am unable to assist you with code due to lack to time.I or Ravi will see if we can find sometime to put the code next week.
Regards
Brajesh
You must be logged in to reply to this topic.