---
title: "lzb/init"
description: "PHP action `lzb/init` of the Lazy Blocks WordPress plugin."
url: "https://www.lazyblocks.com/docs/php-actions/lzb-init/"
lastUpdated: 2026-09-09
source: "php-actions/lzb-init.mdx"
---
# lzb/init

Fires once Lazy Blocks has loaded its classes and its controls, which is the point where `lazyblocks()->add_block()` can be called.

Lazy Blocks hooks this to the WordPress `init` action at priority 5. Its own controls register themselves on `lzb/init` at priority 5, so a handler left at the default priority 10 sees every control type and can reference `text`, `image` or `repeater` by name. Register a block earlier than that and its controls are silently dropped, because `prepare_block_controls()` keeps only the controls whose `type` it recognises.

## Attributes

This action receives no arguments.

## Usage

```php title="PHP"
function my_lzb_init() {
  lazyblocks()->add_block(
    array(
      'title'    => 'Notice',
      'slug'     => 'lazyblock/notice',
      'icon'     => 'dashicons dashicons-info',
      'category' => 'text',
      'controls' => array(
        'control_notice_text' => array(
          'type'    => 'text',
          'name'    => 'notice-text',
          'label'   => 'Notice text',
          'default' => 'Heads up.',
        ),
      ),
      'code'     => array(
        'output_method' => 'html',
        'frontend_html' => '<div useBlockProps class="notice">{{notice-text}}</div>',
      ),
    )
  );
}

add_action( 'lzb/init', 'my_lzb_init' );
```

The array is merged over the block defaults, so every key left out keeps its default value. Two keys have no usable default. `slug` must carry a namespace, and a block without one never reaches `register_block_type()`. The keys of `controls` are arbitrary IDs, while each control needs its own `name`, which is the attribute name the template reads.

Registering blocks from PHP is covered in [Include Lazy Blocks within theme or plugin](https://www.lazyblocks.com/docs/examples/include-lazy-blocks-within-theme-or-plugin/). To change the array before Lazy Blocks stores it, use [lzb/add_user_block](https://www.lazyblocks.com/docs/php-filters/lzb-add_user_block/).

## Documentation Index
> Fetch the complete documentation index at: https://www.lazyblocks.com/llms.txt
> Fetch every page in a single file at: https://www.lazyblocks.com/llms-full.txt
