Change content of $page['content'] variable I have overwritten my login page with a file named page--user--login.tpl.php. Now I have this:

&lt;div class="main-container container"&gt;
  &lt;div class="row-fluid"&gt;
    &lt;section&lt;?php print $content_column_class; ?&gt;&gt;
      &lt;a id="main-content"&gt;&lt;/a&gt;
        &lt;h1&gt;Xmed.be Stocksolutions&lt;/h1&gt;
        &lt;p&gt;"We help you Xchange your stock"&lt;/p&gt;
      &lt;?php print render($title_suffix); ?&gt;
      &lt;?php print $messages; ?&gt;
      &lt;?php if (!empty($page['help'])): ?&gt;
        &lt;?php print render($page['help']); ?&gt;
      &lt;?php endif; ?&gt;
      &lt;?php if (!empty($action_links)): ?&gt;
        &lt;ul class="action-links"&gt;&lt;?php print render($action_links); ?&gt;&lt;/ul&gt;
      &lt;?php endif; ?&gt;
      &lt;?php print render($page['content']); ?&gt;
      &lt;a href="user/register"&gt;NO ACCOUNT? REGISTER&lt;/a&gt;
      &lt;a href="user/password"&gt;FORGOT PASSWORD?&lt;/a&gt;
    &lt;/section&gt;
  &lt;/div&gt;
&lt;/div&gt;


As you can see I added two links at the end (register and password). But I would like them to be inside $page['content'], so that they are in the section. How can I edit the $content variable, loop through it or something?

UPDATE:

Now I've added in my template.php:

function hook_form_user_login_alter(&amp;$form, &amp;$form_state, $form_id) {
    var_dump('test');
}


But I'm not getting test around my form (also looked in html). 

I've also already tried:

function hook_form_alter(&amp;$form, &amp;$form_state, $form_id) {
    dpm($form);
}


But no result or something ...
You can use hook_page_alter to add them into the content array:

function YOUR_MODULE_page_alter(&amp;$page) {

  // Check if this is the correct page.
  if(!isset($page['content']['system_main']['#form_id']) || $page['content']['system_main']['#form_id'] != 'user_login') return;

  // Add links.
  $page['content']['system_main']['register'] = array(
    '#markup' =&gt; '&lt;p&gt;&lt;a href="user/register"&gt;NO ACCOUNT? REGISTER&lt;/a&gt;&lt;/p&gt;',
    '#weight' =&gt; 20
  );
  $page['content']['system_main']['password'] = array(
    '#markup' =&gt; '&lt;p&gt;&lt;a href="user/password"&gt;FORGOT PASSWORD?&lt;/a&gt;&lt;/p&gt;',
    '#weight' =&gt; 21
  );

}


Another option here would be to use hook_form_alter instead. Although hook_form_FORM_ID_alter may well be the most efficient option as it will only run for this specific form removing any overhead from other pages.