Custom user profile titles interfering with user views block I'm using this function to replace the titles on user pages with a user text field:

function MYMODULE_user_view($account, $view_mode, $langcode) {
  $wrapper = entity_metadata_wrapper('user', $account);
  $auth_name = $wrapper-&gt;field_account_auth_name-&gt;value();
  if ($auth_name) {
    drupal_set_title('Profile overview for ' . $auth_name;
  } else {
    drupal_set_title('Profile overview for ' . $account-&gt;name);
  }
}


It works as it should, but when I add a view block with user entities it makes every page have the same title. It's Profile overview for ' . $auth_name; for the first user with a non-empty field_account_auth_name. If I delete that user the next user takes its place. This is for all pages too, not just ones with the block in it.

If it matters I'm using this function

  function MYMODULE_preprocess_user_profile(&amp;$vars) {
    if ($vars['elements']['#view_mode'] == 'auth') {
      $vars['theme_hook_suggestions'][] = 'user_profile__auth';
    }
  }


with a user entity "auth" I created using Entity View Mode, with this in user-profile--auth.tpl:

&lt;div class="authProfile"&lt;?php print $attributes; ?&gt;&gt;
  &lt;?php print render($user_profile); ?&gt;  
&lt;/div&gt;


and setting auth as the view mode in the view block. But the title problem happens with the user account view mode as well.
You could check the url using the arg function and only set the title if the current page is a user/* page. You could try something like the following.

function MYMODULE_user_view($account, $view_mode, $langcode) {
  if (arg(0) == 'user') {
    $wrapper = entity_metadata_wrapper('user', $account);
    $auth_name = $wrapper-&gt;field_account_auth_name-&gt;value();
    if ($auth_name) {
      drupal_set_title('Profile overview for ' . $auth_name;
    } else {
      drupal_set_title('Profile overview for ' . $account-&gt;name);
    }
  }
}