I needed to add some custom, calculated data to a form that involves selection of users from a list. Found what looks like a good home for that in theme_userreference_select (part of CCK's userreference field type). The comments on the function even suggest that it's meant to be overridden.

So, I have it working (code shown below), but I did this right in the original userreference.module file and that doesn't seem kosher.

Anybody suggest where I SHOULD override this function and what it would be called?

/**
 * FAPI theme for an individual elements.
 *
 * The textfield or select is already rendered by the
 * textfield or select themes and the html output
 * lives in $element['#children']. Override this theme to
 * make custom changes to the output.
 *
 * $element['#field_name'] contains the field name
 * $element['#delta]  is the position of this element in the group
 */
function theme_userreference_select($element) {
  return $element['#children'];
}

function theme_userreference_buttons($element)
  {
  // MM mod.
  foreach ( $element['uid']['uid']['#options'] as $uid => $name )
    {
    if ( $uid > 1 )
      {
      $sql = "SELECT vid FROM node WHERE ( status=1 AND uid=".$uid." AND type='available_dates' );";
      if ( $vid = db_result( db_query( $sql )))
        {
        $sql = "SELECT field_available_score_value from content_type_available_dates WHERE vid=".$vid.";" ;
        if ( $score = db_result( db_query( $sql )))
          {
          $repl = $name." (".$score.")";
          $element['#children'] = str_replace( $name, $repl, $element['#children'] );
          }
        }
      }
    }

  return $element['#children'];
}

function theme_userreference_autocomplete($element) {
  return $element['#children'];
}