Sync show creation to external CRM
Three show lifecycle hooks cover the full CRUD lifecycle. benecaster_show_created fires once on first save; benecaster_show_updated fires on every subsequent save with a $changed_fields array listing post-level changes; benecaster_show_deleted fires before the post row is removed. Use to mirror show records in an external CRM, project management tool, or analytics platform.
Code
<?php
add_action( 'benecaster_show_created', function ( int $show_id ) {
my_crm_create_show( [
'wp_id' => $show_id,
// get_the_title() returns HTML (Dave’s Q&A); this is plain text.
'name' => html_entity_decode( get_the_title( $show_id ), ENT_QUOTES, 'UTF-8' ),
'feed_url' => get_post_meta( $show_id, '_benecaster_show_feed_slug', true ),
] );
} );
add_action( 'benecaster_show_updated', function ( int $show_id, array $changed_fields ) {
if ( empty( $changed_fields ) ) {
return;
}
if ( in_array( 'title', $changed_fields, true ) ) {
// get_the_title() returns HTML (Dave’s Q&A); this is plain text.
my_crm_update_show_name( $show_id, html_entity_decode( get_the_title( $show_id ), ENT_QUOTES, 'UTF-8' ) );
}
}, 10, 2 );
add_action( 'benecaster_show_deleted', function ( int $show_id ) {
my_crm_delete_show( $show_id );
} );
Hooks Used
Need this built rather than just documented? See our services →