aside from the admin, there are other roles created by the admin who could also administer and manage users. and because of this, there's a need to hide the admin from being viewed among the list of users and operators. there's a good reason for resorting to this.

in this connection, how do we go about this? what is the best solution for implementing this? please help..

Comments

Help pls on hiding admin-user

i'm sure someone here has got the answer. could you pls share to us the solution? pls help...

the entire drupal community would be very grateful.

Me too...

Yea, I also need an answer to this one.

The only answer I can think of, bearing in mind that there are many many admin screens and virtually every module adds one, is a seperate module that creates, for instance a Moderator role, and then hook calls to admin pages withthe module and do a little sql rewrite or summin...

But that seems awfully complex....

A simpler answer would be most welcome!

ZuluWarrior

ZuluWarrior

same here

same here

__________________________________________________________________________________
www.DrupalBased.com - Showcasing Drupal Powered Sites.

Hi there is a few ways to

Hi there is a few ways to hide the administrator from the users list.

The way I did it was:
[Note: There is also a tutorial that may provide you with a better way of doing this. It is located in the theme developers guide under customizing the user listing page I think.]

// This will stop the root user from showing up in the listing page. This code goes in your profile_listing.tpl.php file.
if($user->uid != '1') {
  // Inside here write your custom theme code.
}

(If your referring to removing the admin from showing up every where on the site, that is a bigger problem and I am still trying to figure that one out)

I need this too. To me this

I need this too. To me this seems so basic, I can't believe that there is not a way to hide admin from the site.

Modify profile.module

I know modifying drupal core is supposed to be a no-no, but this is a really easy one. Find the line in profile.module that looks like:
$result = pager_query('SELECT uid, access FROM {users} WHERE uid > 0 AND status != 0 AND access != 0 ORDER BY access DESC', 20, 0, NULL);
It's in the function "profile_browse" and on line 503 in drupal 5.2.

Change it to:
$result = pager_query('SELECT uid, access FROM {users} WHERE uid > 1 AND status != 0 AND access != 0 ORDER BY access DESC', 20, 0, NULL);

Then user 1 doesn't show up on www.example.com/profile

You'll also need to leave all admin user's profile fields blank so they don't show up in the other profile pages, and don't post anything as admin.

This works for me, but of course it won't work if you have more than one admin account. And there's nothing to prevent someone from going to www.example.com/user/1

Valerie
www.beerreviewjournal.com

In drupal 6 profile_browse can be found in profile_page

If you cant find this line of code...

In drupal 6 profile_browse can be found in profile_pages.inc, instead of profile_module...

With a custom module

I wrote a custom module (for 6.x) to achieve this:

hide_admin.info:

name = Hide Admin
description = Hide administrator account (uid 1) from the users list.
package = CSETID
version = VERSION
core = 6.x

And hide_admin.module:

<?php

function hide_admin_form_alter(&$form, $form_state, $form_id) {
  global
$user;
  if(
$form_id == "user_admin_account" && $user->uid != 1) {
   
$keys = array('name', 'status', 'roles', 'member_for', 'last_access', 'operations');
    foreach(
$keys as $key) {
      unset(
$form[$key][1]);
    }
    unset(
$form['accounts']['#options'][1]);
  }
}

?>

Hope this helps.

Did you have to anything

Did you have to anything beyond making the module and enabling it?

I tried using this instead of changing the code in profile.pages.inc, and I copy/pasted the .info and .module code, and enabled the module, but I still get the admin on my user list.

Try to do a print_r and check

Try to do a print_r and check user #1.

function hide_admin_form_alter(&$form, $form_state, $form_id) {
  global $user;
  if($form_id == "user_admin_account" && $user->uid != 1) {
    $keys = array('name', 'status', 'roles', 'member_for', 'last_access', 'operations');
    foreach($keys as $key) {
      unset($form[$key][1]);
    }
    unset($form['accounts']['#options'][1]);
    print_r($form);
  }
}

Excellent fix

Works for me, perfect solution.

Thanks sirozz

This fix will not working

This Fix will not workin for me.

I have drupal 6.19

Take a look

actually the code works

If you want to see it working, login as another user or modify the code like this

<?php

function hide_admin_form_alter(&$form, $form_state, $form_id) {
  global
$user;
  if(
$form_id == "user_admin_account") {
   
$keys = array('name', 'status', 'roles', 'member_for', 'last_access', 'operations');
    foreach(
$keys as $key) {
      unset(
$form[$key][1]);
    }
    unset(
$form['accounts']['#options'][1]);
  }
}

?>

note I removed && $user->uid != 1 inside the PHP if statement, this way even user 1 can't see himself from the list of user in admin/user/user

You can hide but you can't stop the edit

What good does hiding user 1 from the list if someone can still just go to http://somesite.com/user/1/edit?

If a role has "Administer User" permissions he can edit the admin account and then give himself admin privileges.

There has to be a better solution.

exactly. Im looking for a

exactly. Im looking for a solution of this too. I found module Administer Users by Role, it should do exactly what we want. But it appears to have some bug, in order to add some role permission to edit some other users (belonging to a certain role) you have to give this role "Administer Users" privilege first, but since then, users in this role can edit whoever they want, including admin.

How to stop editing superuser

In addition to Pierco's function you can add the following to it to deny access to /user/1/edit.

if($form_id == "user_profile_form" && $user->uid != 1 && $form['#user']->uid == 1) {
  drupal_access_denied();
  drupal_exit(); 
}

Cheers.

Hello:

I notice that you posted your issue some time back.

Please be aware that you posted your topic
in the 'Deprecated' (no longer used) section of the forums.

That is likely why you never got any replies.

Please note that this "topic" had been "Deprecated"
and will not be seen by typical forum users.

The "Deprecated section of the Forums"
is not actively used and is intended as a library archive
collection of old posts.

The only notice it will get is via notifications
to this topic's 'followers'.

Please "Post new Forum topic" in one of the active forums.

In your case I recommend that you post in the forum
-- Post installation http://drupal.org/forum/22

Drupal 8 is great.
###

I am also looking for a solution

I am also looking for a solution. I came across this thread through a friend. WIsh Drupal had tons of plugins like Wordpress.

Arvind Ranabhat is an entertainment blogger at Mallu.

I just wrote a quick fix for a client of mine

Hilariously enough, I also named the module Hide Admin (sorry Pierco! I found this thread too late)
It works for my situation. Anyone who finds it useful is welcome to use it at their own risk.

Perfect

This perfectly works for me.
Thanks Alex !!

nobody click here