I'm trying to disable the search form, navigation, and user login blocks from being enabled by default. My main goal is to not touch the admin at all because I want to version control this.

Is there a way to disable the blocks with some sort of hook? I'm newb when it comes to php and coding for Drupal so please be kind.


hook_block_info_alter() can be used to alter the default configuration of blocks. From there you can set the status, region, visibility and pages settings that match the wanted configuration. But once the blocks configuration has been written to the database, changes made with this hook will have no effect.

Sadly there is no other hook to configure blocks. But you can write the needed information to the database yourself as part of a custom module or profile hook_install() or hook_update_N() implementation. The standard_install() function from the standard module provide example code for that. If this is done from an hook_update_N implementation or a module, rows for the blocks may already exists in the database. You can then use a merge query for each block to avoid having to deal with the "is this an insert or a an update" question yourself.

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.