views:

45

answers:

2

hi,

I've a View displaying users of my website.

how can i remove the user Anonymous from my View ?

i.e. 35 author 16 voter 0 Anonymous 0 user34

I've tried with a filter "User:Name != Anonymous" but it doesn't work.

This is how the added filter looks like: "User: Name not in Unknown"

thanks

+1  A: 

Add the filter User: Name, and set it to Is not one of. Type in Anonymous and wait for the form autocomplete to find the Anonymous user. Your filter should look like User: Name <> Anonymous.

Here's an export of a View that lists all users except Anonymous:

$view = new view;
$view->name = 'users';
$view->description = '';
$view->tag = '';
$view->view_php = '';
$view->base_table = 'users';
$view->is_cacheable = FALSE;
$view->api_version = 2;
$view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
$handler = $view->new_display('default', 'Defaults', 'default');
$handler->override_option('fields', array(
  'name' => array(
    'label' => 'Name',
    'alter' => array(
      'alter_text' => 0,
      'text' => '',
      'make_link' => 0,
      'path' => '',
      'link_class' => '',
      'alt' => '',
      'prefix' => '',
      'suffix' => '',
      'target' => '',
      'help' => '',
      'trim' => 0,
      'max_length' => '',
      'word_boundary' => 1,
      'ellipsis' => 1,
      'html' => 0,
      'strip_tags' => 0,
    ),
    'empty' => '',
    'hide_empty' => 0,
    'empty_zero' => 0,
    'link_to_user' => 1,
    'overwrite_anonymous' => 0,
    'anonymous_text' => '',
    'exclude' => 0,
    'id' => 'name',
    'table' => 'users',
    'field' => 'name',
    'relationship' => 'none',
  ),
));
$handler->override_option('filters', array(
  'uid' => array(
    'operator' => 'not in',
    'value' => array(
      '0' => 0,
    ),
    'group' => '0',
    'exposed' => FALSE,
    'expose' => array(
      'operator' => FALSE,
      'label' => '',
    ),
    'id' => 'uid',
    'table' => 'users',
    'field' => 'uid',
    'relationship' => 'none',
  ),
));
$handler->override_option('access', array(
  'type' => 'none',
));
$handler->override_option('cache', array(
  'type' => 'none',
));
Mark Trapp
This is exactly what I've done, and the filter looks like: "User: Name not in Unknown". I really did exactly the same steps you suggested.
Patrick
Did you import the view I've provided here? If so, does the Filter say User: Name <> Anonymous?
Mark Trapp
+1  A: 

If you don't have user 0 in your database, then that's the cause of the problem. To fix it you need to run two queries.

INSERT INTO users (uid) VALUES (0);
UPDATE users SET uid = 0 WHERE uid = last_insert_id();

(this is for MySQL).

For your special case with the empty user with uid you can run:

UPDATE users SET uid = 0 WHERE uid = 11;

That should fix your problems. Could be your db version didn't support last_insert_id().

googletorp
uhm I got this error: #1062 - Duplicate entry '' for key 'name' . I've actually noticed there is an user with id "11" and all other fields are empty. I made a screeshot: http://dl.dropbox.com/u/72686/users.png
Patrick
I think WHERE UID should be = 0.
Kevin
@Kevin, since the users table uid is a PK, you wont actually insert a user with uid 0, that's why you need to set it, else 2nd query wouldn't be needed
googletorp
It is? Never knew that.
Kevin
It actually has gone by itself. The user anonymous has been added then somehow (not by me). Altough I cleaned the caches several times. Probably some module did the work.
Patrick

related questions