1

I installed "Form block" and it creates blocks. I want change block title via my module, but it doesn't work.

I create module and set function with hook_block_view:

function zzz_block_view($delta = '') {
  $block = array();
  switch ($delta) {
    case 'user_register':
      global $user;
      // Don't display the form to logged in users or if registration is disabled
      if (!$user->uid && variable_get('user_register', 1)) {
        $block['content']['form'] = drupal_get_form('user_register_form');
        $block['subject'] = t('MY TITLE IS HERE');
      }
      return $block;
  }
}

What did I do wrong?

1 Answer 1

3

hook_block_view() is only invoked for the module that defines the block via hook_block_info().

To alter the content of a block provided by another module, use hook_block_view_alter() instead.

5
  • I tried use hook_block_view_MODULE_DELTA_alter instead hook_block_view_alter() but can't achieve result =(
    – NashGC
    Mar 15, 2017 at 12:05
  • It should do - MYMODULE_block_view_user_user_register_alter right?
    – Clive
    Mar 15, 2017 at 13:15
  • I did like that function mymodule_block_view_user_register_alter(&$data, $block) { $data['subject'] = 'lallal'; }
    – NashGC
    Mar 15, 2017 at 13:26
  • The module's called user, the delta is user_register, so the string is user_user_register. You're missing a user. The example in the previous comment should work
    – Clive
    Mar 15, 2017 at 13:33
  • Unfortunately, it also doesn't work =(
    – NashGC
    Mar 15, 2017 at 13:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.