Best way to modify views output with a custom function? I have view with a block display that shows user profile info and the user's points (from user point module). I want to show the "point level" which is a text string based on the number of points the user has.

How do I add that to the block?

I already have a custom function that returns a text string based on the number of points.

I don't want to use views_PHP anymore because it prevents caching of the block.

Should I use hook_block_view_alter()?
I would much prefer a solution that I would allow Views to the render the text you want directly, so technically, I'm not going to answer your question here.

My suggestion is that you add a new formatter, that you use to directly render the user points as a text string instead. This allows your level to work correctly with all of core, not just one particular block. You can then just add user points twice to the View, with different formatters.

I haven't given the particular code below a proper test, as I don't use user points anywhere, but it's copied and cleaned up from live project where I use do something similar, so I know that it works.

/**
 * Implements hook_field_formatter_info().
 */
function user_level_field_formatter_info() {
  return array(
  'user_level' =&gt; array (
      'label' =&gt; t('User level'),
      'field types' =&gt; array('user_points'),
    ),
  );
}

/**
 * Implements hook_field_formatter_view().
 */
function user_level_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
  $user_level = 'green';

  switch ($items[0]) {
    case &gt; 5000:
      $user_level = 'veteran';
    case &gt; 2500:
      $user_level = 'experienced';
  }

  return array(0 =&gt; array('#markup' =&gt; $user_level));
}


The code above assumes that user points is a real field on the user. If that is not the case, then you can add a new text field on the user, set 'field types' to array('text') instead, and in the formatter grab the number of user points directly from user points, with say a user_load($uid), instead of from $items[0] as I do. You will probably also hide the textfield from user_edit with a hook_form_alter.