Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3441512
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T08:33:43+00:00 2026-05-18T08:33:43+00:00

I need to add some functionality (flush some caches and such) when a Block

  • 0

I need to add some functionality (flush some caches and such) when a Block in Drupal is added, moved, edited or deleted, is there ANY kind of hook for that (or another somewhat Drupal native way) like there is for nodes with hook_nodeapi?

I know there is hook_block but there $op is always list, so its not really any good.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T08:33:44+00:00Added an answer on May 18, 2026 at 8:33 am

    Unfortunately blocks don’t have that kind of signalling mechanism. I would use the forms system to add submit callbacks wherever you need a signal for additional work.

    /**
     * Implementation of hook_form_alter().
     */
    function custom_form_alter(&$form, &$form_state, $form_id) {
      // Overview form.
      if ($form_id == 'block_admin_display_form') {
        $form['#submit'][] = 'custom_block_admin_display_form_submit';
      }
      // Individual block configuration form.
      elseif ($form_id == 'block_admin_configure') {
        $form['#submit'][] = 'custom_block_admin_configure_submit';
      }
    }
    
    /**
     * Submit handler for block overview form.
     */
    function custom_block_admin_display_form_submit($form, &$form_state) {
      cache_clear_all();
    }
    
    /**
     * Submit handler for block configuration form.
     */
    function custom_block_admin_configure_form_submit($form, &$form_state) {
      drupal_set_message(t('You have changed a block. Run for the hills!'));
    }
    

    The one downside to this method is that any alternate approach to configuring blocks won’t work. If someone builds a custom form outside the block module, or if you are using context or panels to move blocks around it won’t help. Of course, since any of those alternate configuration points would also use a form, you can use hook_form_alter() to hack into their submit processes as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to add some new functionality to an existing interface. There are already
I need to add some functionality to the jQuery UI autosearch function. The problem
i need to add some functionality to an asp.net application that allows the positioning
I'm enhancing an open source control to add some functionality that I need, and
I need to add some functionality where the user is allowed to pick ranges
I'm using jQuery Validate for a form. I need to add some functionality so
I am trying to add some specific modular functonality to my application, I need
I need to add some total rows to a table. The code I am
I need to add some accordian style expand/collapse handles to a series of parent
I need to add some lightweight syntactic sugar to JavaScript source code, and process

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.