Support » Plugin: New User Approve » [Plugin: New User Approve] Hiding / restricting admins

  • The plugin works a charm for new registrations and approvals. However I have a question re: admin accounts.

    I used User Role Editor to create a role custom called ‘UserEditor’, who would have no other further capabilities beyond subscribers except to add/approve/deny new users. Then I removed all other pesky roles (‘Author, Contributor’ etc) so that only Admin, UserEditor and Subscriber remain.

    However despite paring the role down as much as possible, I still seem to be able in the plugin as UserEditor to deny admins (this obviously does nothing, just pings an email to that effect), and subsequently approve them (this rewrites their passwords!).

    I googled the code below to hide admins in user lists which works well (can now only see Subscribers in the ‘All Users’ list as UserEditor):

    function yoursite_pre_user_query($user_search) {
    $user = wp_get_current_user();

    if ( $user->roles[0] != ‘administrator’ ) {
    global $wpdb;

    $user_search->query_where =
    str_replace(‘WHERE 1=1’,
    “WHERE 1=1 AND {$wpdb->users}.ID IN (
    SELECT wp_usermeta.user_id FROM $wpdb->usermeta
    WHERE wp_usermeta.meta_key = ‘wp_user_level’
    AND wp_usermeta.meta_value = 0)”,


    However I’m still able to see admins in the plugin’s Approved/Denied lists. Is there an easy way of of either hiding admins from the approval lists, or blocking the ability to approve/deny them?


Viewing 1 replies (of 1 total)
  • Plugin Author Josh Harrison


    I am adding a filter for the users that will make the list of users easier to modify. That way you can check if they are an admin or whatever else you want to do.

    Stay tuned for this update. I am working on other changes and will have it released in the next week.

Viewing 1 replies (of 1 total)
  • The topic ‘[Plugin: New User Approve] Hiding / restricting admins’ is closed to new replies.