Skip to content

Instantly share code, notes, and snippets.

@jesseeproductions
Last active February 13, 2023 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jesseeproductions/51fae129accf50ea791e472f0da23b90 to your computer and use it in GitHub Desktop.
Save jesseeproductions/51fae129accf50ea791e472f0da23b90 to your computer and use it in GitHub Desktop.
Adds a custom field to the event details sent to Zapier through Event Automator
/**
* Adds a custom field to the event details sent to Zapier through Event Automator.
* Replace %%CUSTOMFIELD%% with your field name.
*
* @since 1.0.0
*
* @param array<string|mixed> An array of event details.
* @param WP_Post An instance of the event WP_Post object.
*/
function tec_automator_event_add_custom_field( array $next_event, WP_Post $event ) {
$custom_field = get_post_meta( $event->ID, '%%CUSTOMFIELD%%', true );
if ( ! $custom_field ) {
return $next_event;
}
$next_event['%%CUSTOMFIELD%%'] = $custom_field;
return $next_event;
}
add_filter( 'tec_automator_map_event_details', 'tec_automator_event_add_custom_field', 10, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment