BuddyDev

Search

remove user rows from user table list

  • Participant
    Level: Initiated
    Posts: 11
    waseem on #36882

    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 = admin2

    function 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!

  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #36905

    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
    Brajesh

  • Participant
    Level: Initiated
    Posts: 11
    waseem on #36913

    Hi Brajesh thank you for your response. Can you please give me the codes. I can not understand how to do that.

    thank you

  • Participant
    Level: Initiated
    Posts: 11
    waseem on #36974

    @brajesh
    Could you please give me the code.

    • This reply was modified 3 years, 1 month ago by waseem.
  • Keymaster
    (BuddyDev Team)
    Posts: 24211
    Brajesh Singh on #36993

    Hi 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

  • Participant
    Level: Initiated
    Posts: 11
    waseem on #37174

    @brajeah and @ravi
    have a nice day.
    could you please provide me the code?

    thank you

    • This reply was modified 3 years, 1 month ago by waseem.

You must be logged in to reply to this topic.

This topic is: not resolved