Title: [Plugin: ThreeWP Broadcast] Better action hook patch
Last modified: August 20, 2016

---

# [Plugin: ThreeWP Broadcast] Better action hook patch

 *  [flynsarmy](https://wordpress.org/support/users/flynsarmy/)
 * (@flynsarmy)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-threewp-broadcast-better-action-hook-patch/)
 * We send MailChimp emails out when new posts are published (or broadcasted) however
   the broadcast plugin made it difficult to determine the Post ID of the broadcasted
   posts. The patch below adds an array of blog_id=>post_id to make things easier.
 * **Usage:**
    add_action(‘threewp_activity_monitor_new_activity’, ‘handle_broadcast_posts’);
   function handle_broadcast_posts( $activity ) { foreach ( $activity[‘activity_details’]
   as $details ) { switch_to_blog( $details[‘blog_id’] );
 *  $post = get_post( $details[‘post_id’] );
    …
 *  restore_current_blog();
    } }
 * **Patch:**
    Below `$to_broadcasted_blogs = array(); // Array of blog names that
   we're broadcasting to. To be used for the activity monitor action.` Add `$to_broadcasted_blog_details
   = array(); // Array of blog and post IDs that we're broadcasting to. To be used
   for the activity monitor action.`
 * Below
    `$to_broadcasted_blogs[] = '<a href="' . get_permalink( $new_post_id ).'"
   >' . get_bloginfo( 'name' ) . '</a>';` Add `$to_broadcasted_blog_details[] = 
   array('blog_id'=>$blogID, 'post_id'=>$new_post_id);`
 * Below
 *     ```
       'activity_strings' => array(
       	'' => '%user_display_name_with_link% has broadcasted '.$post_url_and_name.' to: ' . implode( ', ', $to_broadcasted_blogs),
       ),
       ```
   
 * add
    `'activity_details' => $to_broadcasted_blog_details,`
 * [http://wordpress.org/extend/plugins/threewp-broadcast/](http://wordpress.org/extend/plugins/threewp-broadcast/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [flynsarmy](https://wordpress.org/support/users/flynsarmy/)
 * (@flynsarmy)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-threewp-broadcast-better-action-hook-patch/#post-2997472)
 * Patch got screwed up. See here instead [http://pastebin.com/66mQ5MQt](http://pastebin.com/66mQ5MQt)
 *  Thread Starter [flynsarmy](https://wordpress.org/support/users/flynsarmy/)
 * (@flynsarmy)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-threewp-broadcast-better-action-hook-patch/#post-2997486)
 * Added a minor update: [http://pastebin.com/jG37YrHG](http://pastebin.com/jG37YrHG)
   
   This version lets the action know whether the broadcasted post was newly inserted
   or just updated using an ‘inserted’ boolean.
 * //To skip posts that aren’t newly imported:
    foreach ( $activity[‘activity_details’]
   as $details ) { if ( empty($details[‘inserted’]) ) continue;
 *  do_something();
    }
 *  [edward mindreantre](https://wordpress.org/support/users/edward-mindreantre/)
 * (@edward-mindreantre)
 * [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-threewp-broadcast-better-action-hook-patch/#post-2997528)
 * Patch added in 1.12

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘[Plugin: ThreeWP Broadcast] Better action hook patch’ is closed to new
replies.

 * ![](https://ps.w.org/threewp-broadcast/assets/icon.svg?rev=1013783)
 * [Broadcast](https://wordpress.org/plugins/threewp-broadcast/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/threewp-broadcast/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/threewp-broadcast/)
 * [Active Topics](https://wordpress.org/support/plugin/threewp-broadcast/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/threewp-broadcast/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/threewp-broadcast/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [edward mindreantre](https://wordpress.org/support/users/edward-mindreantre/)
 * Last activity: [13 years, 9 months ago](https://wordpress.org/support/topic/plugin-threewp-broadcast-better-action-hook-patch/#post-2997528)
 * Status: not resolved