How to remove link to profile under title, when rendering a profile as block in the module Profile2 I'm rendering a user customer profile in a form using the code:

$profile = profile2_load_by_user($account, 'customer');
$form['customer_profile'] = array(
    '#type' =&gt; 'item',
    '#markup' =&gt; render($profile-&gt;view('block')),
);


which works rather well, except that the title (in H2 tags) is rendered as a link back to the profile.

I want to get rid of that link, but as there seems to be no obvious property, to specify if you do or do not want a backlink. Not in the $build array parameter of hook_entity_view_alter, nor in the $elements parameter for a '#pre_render' callback. In a '#post_render' callback, it's too late because the link is already inserted into html.

So, how do I get rid of it?
This link is part of template file profile2.tpl.php defined as $title and it appear for non page display modes as described by the template code.  

&lt;?php if (!$page): ?&gt;
&lt;h2&lt;?php print $title_attributes; ?&gt;&gt;
    &lt;a href="&lt;?php print $url; ?&gt;"&gt;&lt;?php print $title; ?&gt;&lt;/a&gt;
&lt;/h2&gt;
&lt;?php endif; ?&gt;


The short possible solution can be to unset title variable implementing hook_preprocess_profile2. But to remove whole markup you will have to overwrite theme registry implementing hook_theme_registry_alter(&amp;$theme_registry) to replace template against profile2.

$theme_registry['profile2'] = array(
  'render element' =&gt; 'elements',
  'template' =&gt; 'profile2_custom',
  'path' =&gt; path_to_theme(),
);