Skip to content

Actions and filters

Custom fields: 14 hooks.

Every hook here has a description in the source.

10 actions4 filters

action

davo_custom_field_created

Fires after a new custom field definition is created.

Parameters of davo_custom_field_created
ParameterTypeDescription
$field_idstringNew field's stable ID.
$owner_typestringOwner type slug.
$definitionarray<string, mixed>Newly created, decoded definition.
add_action
add_action( 'davo_custom_field_created', 'my_action_callback', 10, 3 );

/**
 * @param string $field_id
 * @param string $owner_type
 * @param array<string, mixed> $definition
 */
function my_action_callback( $field_id, $owner_type, $definition ) {
	// Your code here.
}

src/domains/custom-fields/services/definitions.php:243

filter

davo_custom_field_definition_response

Filters a custom field definition before it is returned by the API.

Parameters of davo_custom_field_definition_response
ParameterTypeDescription
$definitionarray<string, mixed>The decoded field definition.

Returns array<string, mixed>

add_filter
add_filter( 'davo_custom_field_definition_response', 'my_filter_callback', 10, 1 );

/**
 * @param array<string, mixed> $definition
 */
function my_filter_callback( $definition ) {
	// Change $definition as needed, then return it.
	return $definition;
}

src/domains/custom-fields/helpers.php:269

action

davo_custom_field_deleted

Fires after a custom field definition is deleted.

Parameters of davo_custom_field_deleted
ParameterTypeDescription
$field_idstringDeleted field's stable ID.
$definitionarray<string, mixed>The definition as it existed just before deletion.
$values_purgedboolWhether stored values were also purged.
add_action
add_action( 'davo_custom_field_deleted', 'my_action_callback', 10, 3 );

/**
 * @param string $field_id
 * @param array<string, mixed> $definition
 * @param bool $values_purged
 */
function my_action_callback( $field_id, $definition, $values_purged ) {
	// Your code here.
}

src/domains/custom-fields/services/definitions.php:419

action

davo_custom_field_owner_type_registered

Fires after a content type registers itself as a Custom Fields owner.

Parameters of davo_custom_field_owner_type_registered
ParameterTypeDescription
$owner_typestringNormalized owner type slug.
$definitionarray<string, mixed>Normalized owner-type registration.
add_action
add_action( 'davo_custom_field_owner_type_registered', 'my_action_callback', 10, 2 );

/**
 * @param string $owner_type
 * @param array<string, mixed> $definition
 */
function my_action_callback( $owner_type, $definition ) {
	// Your code here.
}

src/domains/custom-fields/services/owner-registry.php:128

action

davo_custom_field_reordered

Fires after a Custom Fields owner type's field order is changed.

Parameters of davo_custom_field_reordered
ParameterTypeDescription
$owner_typestringOwner type slug.
$orderarray<string>New field_id order.
add_action
add_action( 'davo_custom_field_reordered', 'my_action_callback', 10, 2 );

/**
 * @param string $owner_type
 * @param array<string> $order
 */
function my_action_callback( $owner_type, $order ) {
	// Your code here.
}

src/domains/custom-fields/services/definitions.php:605

action

davo_custom_field_schema_changed

Fires once after any change to an owner type's field definitions (create, update, delete, or reorder) that could affect its public schema — a single, coarse-grained signal for cache invalidation, distinct from the four granular lifecycle actions above which describe *what* changed.

Parameters of davo_custom_field_schema_changed
ParameterTypeDescription
$owner_typestringOwner type slug whose schema changed.
$versionintNew schema version number for this owner type.
add_action
add_action( 'davo_custom_field_schema_changed', 'my_action_callback', 10, 2 );

/**
 * @param string $owner_type
 * @param int $version
 */
function my_action_callback( $owner_type, $version ) {
	// Your code here.
}

src/domains/custom-fields/services/definitions.php:646

filter

davo_custom_field_schema_response

Filters the public schema of a custom field before it is returned.

Parameters of davo_custom_field_schema_response
ParameterTypeDescription
$schemaarray<string, mixed>The schema: field ID, type, name, label, description, placeholder, default value, required, order, section, validation, options, configuration, placement and visibility.
$definitionarray<string, mixed>The full decoded definition.

Returns array<string, mixed>

add_filter
add_filter( 'davo_custom_field_schema_response', 'my_filter_callback', 10, 2 );

/**
 * @param array<string, mixed> $schema
 * @param array<string, mixed> $definition
 */
function my_filter_callback( $schema, $definition ) {
	// Change $schema as needed, then return it.
	return $schema;
}

src/domains/custom-fields/helpers.php:294

filter

davo_custom_field_types

Filters the registered custom field types. Add a type here to make it available.

Parameters of davo_custom_field_types
ParameterTypeDescription
$typesarray<string, array<string, mixed>>Type slug => type definition. Defaults to the built-in types.

Returns array<string, array<string, mixed>>

add_filter
add_filter( 'davo_custom_field_types', 'my_filter_callback', 10, 1 );

/**
 * @param array<string, array<string, mixed>> $types
 */
function my_filter_callback( $types ) {
	// Change $types as needed, then return it.
	return $types;
}

src/domains/custom-fields/services/type-registry.php:54

action

davo_custom_field_updated

Fires after a custom field definition is updated.

Parameters of davo_custom_field_updated
ParameterTypeDescription
$field_idstringField's stable ID.
$definitionarray<string, mixed>Updated, decoded definition.
$previousarray<string, mixed>Definition before this update.
add_action
add_action( 'davo_custom_field_updated', 'my_action_callback', 10, 3 );

/**
 * @param string $field_id
 * @param array<string, mixed> $definition
 * @param array<string, mixed> $previous
 */
function my_action_callback( $field_id, $definition, $previous ) {
	// Your code here.
}

src/domains/custom-fields/services/definitions.php:353

action

davo_custom_field_values_cleared

Fires after custom field values are explicitly cleared for an object.

Parameters of davo_custom_field_values_cleared
ParameterTypeDescription
$owner_typestringOwner type slug.
$object_idintThe owning object's ID.
$field_idsarray<string>Cleared field IDs.
add_action
add_action( 'davo_custom_field_values_cleared', 'my_action_callback', 10, 3 );

/**
 * @param string $owner_type
 * @param int $object_id
 * @param array<string> $field_ids
 */
function my_action_callback( $owner_type, $object_id, $field_ids ) {
	// Your code here.
}

src/domains/custom-fields/services/values.php:422

action

davo_custom_field_values_deleted

Fires after every custom field value is deleted for an object.

Parameters of davo_custom_field_values_deleted
ParameterTypeDescription
$owner_typestringOwner type slug.
$object_idintThe owning object's ID.
add_action
add_action( 'davo_custom_field_values_deleted', 'my_action_callback', 10, 2 );

/**
 * @param string $owner_type
 * @param int $object_id
 */
function my_action_callback( $owner_type, $object_id ) {
	// Your code here.
}

src/domains/custom-fields/services/values.php:458

action

davo_custom_field_values_saved

Fires after a batch of custom field values is saved for an object.

Parameters of davo_custom_field_values_saved
ParameterTypeDescription
$owner_typestringOwner type slug.
$object_idintThe owning object's ID.
$validated_valuesarray<string, mixed>field_id => saved value.
add_action
add_action( 'davo_custom_field_values_saved', 'my_action_callback', 10, 3 );

/**
 * @param string $owner_type
 * @param int $object_id
 * @param array<string, mixed> $validated_values
 */
function my_action_callback( $owner_type, $object_id, $validated_values ) {
	// Your code here.
}

src/domains/custom-fields/services/values.php:397

filter

davo_custom_fields_public_schema

Filters the public schema of an owner type before it is returned.

Only the output handed to visitors passes through here, never the admin builder's data, so it is the safe place to translate labels for the current language.

Parameters of davo_custom_fields_public_schema
ParameterTypeDescription
$schemaarray{fields: array<array<string, mixed>>, sections: array<array<string, mixed>>}Public schema.
$owner_typestringOwner type slug.
add_filter
add_filter( 'davo_custom_fields_public_schema', 'my_filter_callback', 10, 2 );

/**
 * @param array{fields: array<array<string, mixed>>, sections: array<array<string, mixed>>} $schema
 * @param string $owner_type
 */
function my_filter_callback( $schema, $owner_type ) {
	// Change $schema as needed, then return it.
	return $schema;
}

src/domains/custom-fields/repository.php:147

action

davo_register_custom_field_owner_types

Fires once at init (priority 5) so a content-type domain can register itself as a Custom Fields owner. See Custom_Fields_Owner_Registry::register()'s docblock for the full registration example.

Parameters of davo_register_custom_field_owner_types
ParameterTypeDescription
$registryCustom_Fields_Owner_RegistryShared owner-type registry instance.
add_action
add_action( 'davo_register_custom_field_owner_types', 'my_action_callback', 10, 1 );

/**
 * @param Custom_Fields_Owner_Registry $registry
 */
function my_action_callback( $registry ) {
	// Your code here.
}

src/domains/custom-fields/initializer.php:256

Note. Generated from the plugin source. Descriptions and parameters are the ones written in the code. The starter code uses the parameter names from those comments, or generic names where there are none, so check them against your use.

See it on your own site.

Davo is a WordPress theme and plugin by Exorex.

  • Runs on your own WordPress
  • Guided setup wizard
  • AI is off until you switch it on
  • Read the licence on the marketplace first