Created
April 8, 2026 11:09
-
-
Save cdevroe/e61ddf1f1c714f62b1f99b0ecdd38114 to your computer and use it in GitHub Desktop.
Send custom field metadata to Flodesk using Hubbub Save This
This file contains hidden or 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
| <?php | |
| /** | |
| Add subscriber metadata to Flodesk using Hubbub Save This | |
| https://morehubbub.com/ | |
| https://morehubbub.com/docs/save-this-actions-and-filters/ | |
| Important: in Flodesk, custom_fields keys need to | |
| match real Flodesk custom field keys. If your fields are | |
| not keyed exactly post_id, post_title, and post_url, | |
| replace those array keys with the keys from | |
| your Flodesk account. | |
| https://help.flodesk.com/en/articles/4748737 | |
| **/ | |
| add_filter( | |
| 'hubbub_save_this_filter_subscriber_data', | |
| function( $subscriber_data, $post_id, $is_shortcode ) { | |
| // Only modify the Flodesk payload. | |
| if ( ! array_key_exists( 'segment', $subscriber_data ) ) { | |
| return $subscriber_data; | |
| } | |
| $post_url = get_permalink( $post_id ); | |
| $subscriber_data['custom_fields'] = array_merge( | |
| isset( $subscriber_data['custom_fields'] ) && is_array( $subscriber_data['custom_fields'] ) | |
| ? $subscriber_data['custom_fields'] | |
| : array(), | |
| array( | |
| 'post_id' => (string) $post_id, | |
| 'post_title' => wp_strip_all_tags( get_the_title( $post_id ) ), | |
| 'post_url' => $post_url ? esc_url_raw( $post_url ) : '', | |
| ) | |
| ); | |
| return $subscriber_data; | |
| }, | |
| 10, | |
| 3 | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment