add_action("init","my_functions"); function my_functions(){ remove_action('save_post', 'bp_blogs_record_post'); add_action( 'save_post', 'my_blogs_record_post', 10, 2 ); } function my_blogs_record_post( $post_id, $post, $user_id = false ) { global $bp, $wpdb; $post_id = (int)$post_id; $blog_id = (int)$wpdb->blogid; if ( !$user_id ) $user_id = (int)$post->post_author; /* This is to stop infinite loops with Donncha's sitewide tags plugin */ if ( (int)$bp->site_options['tags_blog_id'] == (int)$blog_id ) return false; /* Don't record this if it's not a post */ if ( $post->post_type != 'post' ) return false; if ( 'publish' == $post->post_status && '' == $post->post_password ) { if ( (int)get_blog_option( $blog_id, 'blog_public' ) || !bp_core_is_multisite() ) { /* Record this in activity streams */ $post_permalink = get_permalink( $post_id ); $activity_action = sprintf( __( '%s wrote a new blog post: %s', 'buddypress' ), bp_core_get_userlink( (int)$post->post_author ), '' . $post->post_title . '' ); $activity_content = get_the_post_thumbnail( $post_id ); my_blogs_record_activity( array( 'user_id' => (int)$post->post_author, 'action' => apply_filters( 'bp_blogs_activity_new_post_action', $activity_action, &$post, $post_permalink ), 'content' => apply_filters( 'bp_blogs_activity_new_post_content', $activity_content, &$post, $post_permalink ), 'primary_link' => apply_filters( 'bp_blogs_activity_new_post_primary_link', $post_permalink, $post_id ), 'type' => 'new_blog_post', 'item_id' => $blog_id, 'secondary_item_id' => $post_id, 'recorded_time' => $post->post_date_gmt )); } } else bp_blogs_remove_post( $post_id, $blog_id ); bp_blogs_update_blogmeta( $blog_id, 'last_activity', gmdate( "Y-m-d H:i:s" ) ); do_action( 'bp_blogs_new_blog_post', $post_id, $post, $user_id ); } function my_blogs_record_activity( $args = '' ) { global $bp; if ( !function_exists( 'bp_activity_add' ) ) return false; /* Because blog, comment, and blog post code execution happens before anything else we may need to manually instantiate the activity component globals */ if ( !$bp->activity && function_exists('bp_activity_setup_globals') ) bp_activity_setup_globals(); $defaults = array( 'user_id' => $bp->loggedin_user->id, 'action' => '', 'content' => '', 'primary_link' => '', 'component' => $bp->blogs->id, 'type' => false, 'item_id' => false, 'secondary_item_id' => false, 'recorded_time' => gmdate( "Y-m-d H:i:s" ), 'hide_sitewide' => false ); $r = wp_parse_args( $args, $defaults ); extract( $r, EXTR_SKIP ); if ( !empty( $action ) ) $action = apply_filters( 'bp_blogs_record_activity_action', $action ); /* Check for an existing entry and update if one exists. */ $id = bp_activity_get_activity_id( array( 'user_id' => $user_id, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id ) ); return bp_activity_add( array( 'id' => $id, 'user_id' => $user_id, 'action' => $action, 'content' => $content, 'primary_link' => $primary_link, 'component' => $component, 'type' => $type, 'item_id' => $item_id, 'secondary_item_id' => $secondary_item_id, 'recorded_time' => $recorded_time, 'hide_sitewide' => $hide_sitewide ) ); }