Created
May 11, 2015 21:43
-
-
Save bappi-d-great/9e84dcf73e0dcb3012ce to your computer and use it in GitHub Desktop.
Add wiki activities in BuddyPress activities
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_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