ExpressionEngine Docs

# TemplateGroup Model Extension Hooks

- `before_template_group_insert($template_group, $values)`
- `after_template_group_insert($template_group, $values)`
- `before_template_group_update($template_group, $values, $modified)`
- `after_template_group_update($template_group, $values, $modified)`
- `before_template_group_save($template_group, $values)`
- `after_template_group_save($template_group, $values)`
- `before_template_group_delete($template_group, $values)`
- `after_template_group_delete($template_group, $values)`
- `before_template_group_bulk_delete($delete_ids)`
- `after_template_group_bulk_delete($delete_ids)`

### `before_template_group_insert($template_group, $values)`

Parameter | Type | Description
--- | --- | ---
$template_group | `Object` | Current TemplateGroup model object
$values | `Array` | The TemplateGroup model object data as an array
Returns | `NULL` | void

Called before the template group object is inserted. Changes made to the object will be saved automatically.

How it’s called:

    ee()->extensions->call('before_template_group_insert', $this, $this->getValues());

### `after_template_group_insert($template_group, $values)`

Parameter | Type | Description
--- | --- | ---
$template_group | `Object` | Current TemplateGroup model object
$values | `Array` | The TemplateGroup model object data as an array
Returns | `NULL` | void

Called after the template group object is inserted. Changes made to the object object will not be saved automatically. Saving the object may trigger the save and update hooks.

How it’s called:

    ee()->extensions->call('after_template_group_insert', $this, $this->getValues());

### `before_template_group_update($template_group, $values, $modified)`

Parameter | Type | Description
--- | --- | ---
$template_group | `Object` | Current TemplateGroup model object
$values | `Array` | The TemplateGroup model object data as an array
$modified | `Array` | An array of all the old values that were changed
Returns | `NULL` | void

Called before the template group object is updated. Changes made to the object will be saved automatically.

How it’s called:

    ee()->extensions->call('before_template_group_update', $this, $this->getValues(), $modified);

### `after_template_group_update($template_group, $values, $modified)`

Parameter | Type | Description
--- | --- | ---
$template_group | `Object` | Current TemplateGroup model object
$values | `Array` | The TemplateGroup model object data as an array
$modified | `Array` | An array of all the old values that were changed
Returns | `NULL` | void

Called after the template group object is updated. Changes made to the object will not be saved automatically. Calling save may fire additional hooks.

How it’s called:

    ee()->extensions->call('after_template_group_update', $this, $this->getValues(), $modified);

### `before_template_group_save($template_group, $values)`

Parameter | Type | Description
--- | --- | ---
$template_group | `Object` | Current TemplateGroup model object
$values | `Array` | The TemplateGroup model object data as an array
Returns | `NULL` | void

Called before the template group object is inserted or updated. Changes made to the object will be saved automatically.

How it’s called:

    ee()->extensions->call('before_template_group_save', $this, $this->getValues());

### `after_template_group_save($template_group, $values)`

Parameter | Type | Description
--- | --- | ---
$template_group | `Object` | Current TemplateGroup model object
$values | `Array` | The TemplateGroup model object data as an array
Returns | `NULL` | void

Called after the template group object is inserted or updated. Changes made to the object will not be saved automatically. Calling save may fire additional hooks.

How it’s called:

    ee()->extensions->call('after_template_group_save', $this, $this->getValues());

### `before_template_group_delete($template_group, $values)`

Parameter | Type | Description
--- | --- | ---
$template_group | `Object` | Current TemplateGroup model object
$values | `Array` | The TemplateGroup model object data as an array
Returns | `NULL` | void

Called before the template group object is deleted. If you are conditionally deleting one of your own models, please consider creating an inverse relationship instead. This will provide better performance and strictly enforce data consistency.

How it’s called:

    ee()->extensions->call('before_template_group_delete', $this, $this->getValues());

### `after_template_group_delete($template_group, $values)`

Parameter | Type | Description
--- | --- | ---
$template_group | `Object` | Current TemplateGroup model object
$values | `Array` | The TemplateGroup model object data as an array
Returns | `NULL` | void

Called after the template group object is deleted. If you are conditionally deleting one of your own models, please consider creating an inverse relationship instead. This will provide better performance and strictly enforce data consistency.

How it’s called:

    ee()->extensions->call('after_template_group_delete', $this, $this->getValues());

### `before_template_group_bulk_delete($delete_ids)`

Parameter | Type | Description
--- | --- | ---
$delete_ids | `Array` | The primary key IDs of the models being deleted
Returns | `NULL` | void

Called before a bulk of template group objects are deleted. If you need to do an expensive operation when template groups are deleted, it may be more efficient to handle it in bulk here.

How it’s called:

    ee()->extensions->call('before_template_group_bulk_delete', $delete_ids);

New in version 4.3.0.

### `after_template_group_bulk_delete($delete_ids)`

Parameter | Type | Description
--- | --- | ---
$delete_ids | `Array` | The primary key IDs of the models being deleted
Returns | `NULL` | void

Called after a bulk of template group objects are deleted. If you need to do an expensive operation when template groups are deleted, it may be more efficient to handle it in bulk here.

How it’s called:

    ee()->extensions->call('after_template_group_bulk_delete', $delete_ids);

New in version 4.3.0.