WP Webhooks / Docs / fswa_normalize_object
Filter since v1.5.0

fswa_normalize_object

Converts custom PHP objects in hook arguments into plain arrays for JSON serialization.

$

/ Signature

apply_filters( 'fswa_normalize_object', $data, $object, $class_name )

/ When it fires

Fires for each PHP object encountered when serializing WordPress hook arguments to JSON.

/ Parameters

NameInTypeReqDescription
$dataparammixedyesCurrent normalized value — `null` initially. Return an array to replace the object.
$objectparamobjectyesThe PHP object to normalize.
$class_nameparamstringyesClass name of the object (e.g. `WPCF7_Submission`).

/ Returns

array|null Return an array to use as the object's representation. Return `null` to skip (plugin's default reflection-based normalization runs).

/ Examples

Normalize a custom form submission object

add_filter( 'fswa_normalize_object', function ( $data, $object, $class_name ) {
    if ( $class_name !== 'My_Form_Submission' ) return $data;
    return [
        'form_id' => $object->get_form_id(),
        'fields'  => $object->get_fields(),
    ];
}, 10, 3 );

/ Related

Ready

Stop losing webhooks.
Start logging them.

$ wp plugin install flowsystems-webhook-actions --activate