Skip to content

Instantly share code, notes, and snippets.

@bappi-d-great
Created May 11, 2015 21:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bappi-d-great/9e84dcf73e0dcb3012ce to your computer and use it in GitHub Desktop.
Save bappi-d-great/9e84dcf73e0dcb3012ce to your computer and use it in GitHub Desktop.
Add wiki activities in BuddyPress activities
<?php
add_action( 'save_post', 'add_wiki_activity_to_bp' );
function add_wiki_activity_to_bp( $post_id ) {
if( get_post_type( $post_id ) == 'incsub_wiki' ) {
if ( ! function_exists( 'bp_activity_add' ) ) return false;
$user_id = get_current_user_id();
$user_info = get_userdata( $user_id );
$post = get_post( $post_id );
if( ( $_POST['post_status'] == 'publish' ) && ( $_POST['original_post_status'] != 'publish' ) ) {
bp_activity_add( array(
'user_id' => $user_id,
'action' => bp_core_get_userlink( $user_id ) . ' has published <a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a>',
'component' => 'profile',
'type' => 'created_wiki'
) );
}elseif( ( $_POST['post_status'] == 'publish' ) ) {
bp_activity_add( array(
'user_id' => $user_id,
'action' => bp_core_get_userlink( $user_id ) . ' has edited <a href="' . get_permalink( $post->ID ) . '">' . $post->post_title . '</a>',
'component' => 'profile',
'type' => 'created_wiki'
) );
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment