Last active
February 13, 2023 14:38
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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