Modifying custom field lists in realtime

The custom field lists (black, protect, white) can be modified in realtime during broadcast.

The snippet below shows two things: how to modify the custom field lists just before broadcasting starts, and how to remove a custom field from the broadcast completely (so that it isn’t sent to the children).

// Prio < 10 since lots of add-ons hook into _started in order to begin their processing.
add_action( 'threewp_broadcast_broadcasting_started', 'my_threewp_broadcast_broadcasting_started', 5 ); function my_threewp_broadcast_broadcasting_started( $action ) { // Check that the user has chosen to broadcast the custom fields. if ( ! $action->broadcasting_data->custom_fields )
		return;

	// Convenience.
	$bcd = $action->broadcasting_data;

	// Add something to the custom field blacklist.
	$bcd->custom_fields->blacklist []= 'author_image_id';

	// There's a ->whitelist and ->protectlist also.

	// Since broadcasting_started is called after the fields have been processed by Broadcast,
	// remove any unwanted custom fields manually.
	$bcd->custom_fields()->forget( '_edit_last' );
}