drupal_goto not working in hook_init First some introduction:

The hook is working in other pages or direct urls.
The only situation where is not working is in the find content page, "admin/content".

When the user clicks on edit link, drupal loads the node edit page, but we need to redirect that edit page to our own edit page. That's why we use the code in the hook.

THE PROBLEM:

When the user clicks on edit, he or she is redirected to the same page again (Find content). Intead of going to the my_module edit page. I Don't know why it's happening this. Any help is welcome :)

The Code:

function my_module_init() {

    // redirect drupal edit page to our own module edit page.
    if (preg_match('/^node\/(\d+)\/edit$/', current_path(), $matches)) {
      $code = _my_module_check_code($matches[1]); //check if the nid is of the content type we need
      if ($code) {
        return drupal_goto('my_module/' . $code . '/edit');
      }
      // If the code is not from the content type we need, we do nothing 
      // just leave drupal work it's way
    }

}
The solution is to use the hook_preprocess_page().

function my_module_preprocess_page() {

    // redirect drupal edit page to our own module edit page.
    if (preg_match('/^node\/(\d+)\/edit$/', current_path(), $matches)) {
      $code = _my_module_check_code($matches[1]); //check if the nid is of the content type we need
      if ($code) {
        global $base_url;
        $url = $base_url.'/my_module/'.$code.'/edit';
        header('Location: ' . $url);
      }
      // If the code is not from the content type we need, we do nothing 
      // just leave drupal work it's way
    }

}


After clearing cache, all is working fine.