I need to create a custom submit handler when blocks that are assigned to a certain region are saved (whether an existing or a new block)

I am using :

function MY_MODULE_NAME_form_alter(&$form, $form_state, $form_id) {
  if ($form['#id'] == 'block-admin-configure'){

    //If the block being saved is in region "Header" then do something

Can someone tell me what to replace my commented line with please ?

  • What if the theme it's being saved in doesn't have a "header"region?
    – Clive
    Jan 31, 2017 at 16:06
  • This functionality is just for a custom module for a specific client & theme.
    – wotney
    Jan 31, 2017 at 16:17
  • Attach a submit handler, in that handler loop over array_filter($form_state['regions']), that contains the selected regions by machine name
    – Clive
    Jan 31, 2017 at 16:22
  • Thanks Clive, but can you give me an example?... when I view the properties for $form_state, regions isn't there.
    – wotney
    Feb 1, 2017 at 11:46

1 Answer 1


You can implement hook_block_save($delta = '', $edit = array()) to execute your custom code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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