WordPress.org

Forums

New User Approve
Hiding / restricting admins (2 posts)

  1. valvova
    Member
    Posted 3 years ago #

    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):

    add_action('pre_user_query','yoursite_pre_user_query');
    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)",
    $user_search->query_where
    );

    }
    }

    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?

    Cheers!

    http://wordpress.org/extend/plugins/new-user-approve/

  2. Josh Harrison
    Member
    Plugin Author

    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • New User Approve
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags

No tags yet.