It's possible to create a view to get a list of user names of users that signed up for a particular node. But how to get a list of user pictures?

Has anyone managed to do this before?

Comments

dww’s picture

Version: 5.x-2.4 » 6.x-1.0-rc1
Status: Active » Fixed

Not really feasible with D5 views, sorry. If you upgrade to D6, views2 makes this Real Easy(tm), since signup provides a "relationship" between the signup info and the user account. So, you can make a view of "users signed up to this node" and include any user-related fields at all -- user picture, fields from their profile, whatever you want.

beatelic’s picture

I did it in D5 changing the views.inc file. Sorry, but WinMerge won't give me a right patch...

I added a field:

      'picture' => array(
        'name' => t('Signup: User: Image'),
        'handler' => 'views_handler_field_uid_image',
        'sortable' => TRUE,
        'field' => 'uid',
        'help' => t('Users Image of an authenticated user who signed up, or %anonymous for anonymous signups.', array('%anonymous' => variable_get('anonymous', t('Anonymous')))),
      ),

and a handler

function views_handler_field_uid_image($fieldinfo, $fielddata, $value, $data) {
  if (isset($value)) {
    $account = user_load(array('uid' => $value));
    return theme('user_picture', $account);
  }
}

It's just based on how uid und email work. Copied, pasted and changed the values..

dww’s picture

Right, in D5 you can manually create a bunch of custom handlers like this. Total PITA. In D6 it's automated by the relationship. So I won't be committing any changes like that to D5 signup since a) it's already solved in D6, b) D5 is in feature freeze, and c) this is a total rat hole... if I add this, what about the other 30 fields from the $user object people might want to add?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for two weeks with no activity.

socialnicheguru’s picture

Status: Closed (fixed) » Active

does the D6 way work for anonymous users?

i would like to list them too.

Thanks,
Chris

dww’s picture

Status: Active » Closed (fixed)

Anonymous users don't have usernames.

In D6, you can also make a view directly of signups (instead of a view of users and their related signups, or a view of nodes and the signups related to each node). And, in your signup view, you can include the fields from your custom signup form. And, you can include a relationship to the users to pull other fields for your authenticated users. But, anonymous users have no other fields, so there's nothing to have a relationship with. That's what it means that they're "anonymous".