WordPress.org

Ready to get started?Download WordPress

Forums

ThreeWP Broadcast
Better action hook patch (4 posts)

  1. flynsarmy
    Member
    Posted 1 year ago #

    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/

  2. flynsarmy
    Member
    Posted 1 year ago #

    Patch got screwed up. See here instead http://pastebin.com/66mQ5MQt

  3. flynsarmy
    Member
    Posted 1 year ago #

    Added a minor update: 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();
    }

  4. edward mindreantre
    Member
    Posted 1 year ago #

    Patch added in 1.12

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.