Hello Guys,

I need to hide several users from the site.
I mean, I have admin user and several operators who have different administrative roles.

And of course everybody can view them. And I need this group of users (admin, op1, op2, etc.) to be not visible on the site.

Are there any way to do it ? I mean any existing solution for this ....

Thanks.

Comments

Juan Mellado’s picture

At first, are you speaking about "Who's online?" block?

If so, ...

Locate this line (552 for me) on function user_block of user.module file:

$users = db_query('SELECT DISTINCT(uid), MAX(timestamp) AS max_timestamp FROM {sessions} WHERE timestamp >= %d AND uid != 0 GROUP BY uid ORDER BY max_timestamp DESC', time() - $time_period );

And changed it by this:

$users = db_query('SELECT DISTINCT(uid), MAX(timestamp) AS max_timestamp FROM {sessions} WHERE timestamp >= %d AND uid != 0 AND uid NOT IN (XXX) GROUP BY uid ORDER BY max_timestamp DESC', time() - $time_period );

The only difference is the "AND uid NOT IN (XXX)" expression. Change "XXX" and put the list of users IDs that you don´t want to appear in the list.

By example, to avoid list Administrator (always UID=1) set "AND uid NOT IN (1)". To avoid list users with IDs 1, 4 and 5 set "AND uid NOT IN (1, 4, 5)". And so on...

The BIG problem with this solution is that you must remember to change it again after each update of Drupal files or when you want to add new "hidden" users. It's a bit hard, I know. I don't like this, really.

A better solution can be create a custom PHP block, instead of use the default one, copying some current code from user.module used to display the list of users in the same way.

----------------------------------------
www.inmensia.com

ardas’s picture

Even this solution won't give the necessary result. Because saying 'hide from site' I ment hide from search also.

So, as I understood there nothing better than to hack Drupal's kernel, search module and every other necessary modules to implement this feature ?

Regards,
Dmitry Kresin, ARDAS group - Drupal consulting and services, web site development.

seth97’s picture

Hi Duke,
I have been thinking of the same thing. It is irritating that everybody can view “admin”, “admin2” and “admin3” etc when you click on the “user list”…..
I would really like to hide all administrators on the site from the normal users!

Do you have any solutions?

Thanks!
/Seth

lucyconnuk’s picture

I'm looking at this too! Any ideas?

Lucy C

ardas’s picture

I see only one normal solution - is to patch all necessary modules to support this feature.
1. Add one more column to 'users' table to store VISIBLE flag
2. Patch user.module to make VISIBLE flag available for admin when editing user's account.
3. Patch user.module to add VISIBLE flag support in all querries.
4. Patch all other modules (if necessary) to add VISIBLE flag support in all querries. For instance, patch search.module to ommit users who are invisible ...

May be I'll implement such things in the nearest future ... Unfortunatly, I don't have time right now to attend to this question :(

Are there any other ideas on how to implement these features ?

Thanks.

oliver soell’s picture

to have specified user roles which are "hidden" rather than modifying the user table. the roles which would be hidden could be defined in the user access section, for instance, in the user module. but then, what would happen then when a hidden user would post? to whom would that post be attributed? should they not be allowed to post, or to post certain node types?

ardas’s picture

Hidden users can post as well but they should not be visible through the site.
For instance, user "admin" and "operator" exist but hidden. These users will post content (news, products, etc.) but other usual visitors will not see them on the site.

karldied’s picture

How about using the profile module?

In administer > settings > profile
create a check box field, "profile_hidden"
and then use this as a criterian somehow?
I don't know if it can be tied into a category, but if it could, then taxonomy_access could hide it.

jeffleeismyhero’s picture

I would like something like this as well...

baronmunchowsen’s picture

This functionality would be an excellent addition. At present I am using a custom checkbox field and then in my

profile_listing.tpl.php

user_profile.tpl.php

pages using this as a flag to determine whether to show the content or not. Not the pretty, but satisfies my needs for now...

ardas’s picture

This is exactly what I'm doing too since I didn't find anything better :)
----------------
Regards,
Dmitry Kresin, ARDAS group (www.ardas.dp.ua)

seth97’s picture

In case anyone missed it:

http://drupal.org/node/45873

If you also want to hide a specific user (e.g. user 1) you can use:

if ((!in_array('site admin', $user->roles)) && (($user->uid) != "1")):

/Seth

jocrenalix’s picture

As i am trying to figure out, this solution fills the answer i am looking for, but where is this file going to go?

daniel_h’s picture

Seth only gave a hint on how the syntax would look like to conditionally hide a specific user in the generation of some output.
It would need to be done everywhere users appear (profile, lists, boxes ...).

This is not a code for a single file :)

jet_lee’s picture

i am also looking for a solution on how to hide admin from other privileged users. i installed members module but it doesnt hide admin or any other user. is it because it applies to "members" as different from "users"? any other module that provides a solution for this?

when there are several operators administering the site, i think it is wise to make someone (that is the super admin) who cannot be viewed from the list of users or nor edited by another operator who also has the permission to administer users.

as for the code shown by seth, how could this be used in drupal 5.x? how could we implement this? anyone who could share to us the solution?

totaldrupal’s picture

I'm looking for this too in 5x. Is there at least a way to prevent other admin from changing user 1 username and password but letting them still edit users?

ardas’s picture

As I know, there is no such feature. You should implement this manually - implement hook_form_alter() and disable fields depending on the admin role or any other criteria.
----------------
Regards,
Dmitry Kresin, ARDAS group - Web site development, Drupal services, Software development, IT outsourcing.

silkscreen’s picture

Would be very cool if we can hide users easily. Consider that we can publish / unpublish content. Why not users in the user list. Simply hide from view, there are so many advantages, Authors Authors Authors. There must be a way without reverting to 4x code etc. If not, please consider this for D7.

silkscreen’s picture

Seems as though hiding by role would be the answer..? -- filtered somehow maybe http://drupal.org/project/taxonomy_hide -- there is no clear answer to this question ANYWHERE that i can find. In any CMS the admin and indeed any user should be able to include or exclude themselves from the general user list.

To state the obvious, lack of this function is rather silly. Call it what you will, but we, as Authors should have the option to remain anon and in the shadows. Why create a core "user list" that cannot be changed, when every other aspect of content has permissions? Seems like this is a real problem in the core.

IE - A user with the correct privileges can change anything, the visibility of content, publish or unpublish, but they can not hide or unhide their own profile listing.....? Why? Seems Weird and Strange....