Plugin Development – Functions or Hooks?

Below I’ve included two hooks you could use. There may be better hooks depending on what you’re trying to accomplish exactly but this is what you’ve asked for. At the bottom I’ve listed some helpful resources:

Publish Post Hook

http://codex.wordpress.org/Plugin_API/Action_Reference/publish_post

function published_post( $ID, $post ) {
    if( $post->post_type == 'post' ) {
        ...
    }

    if( $post->post_type == 'page' ) {
        ...
    }
}
add_action( 'publish_post', 'published_post', 10, 2 );

Comment Post Hook

function maybe_published_comment( $ID, $approval_bool ) {
    ...
}
add_action( 'comment_post', maybe_published_comment, 10, 2 );

Resources

  1. Action Reference
  2. Developer Reference
    1. WP_Publish_Post()
    2. Comment Post Hook