Advertisement
pjeaje

Only allow post author to reply to a comment on their post

Jan 29th, 2015
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. add_action( 'pre_comment_on_post', 'wpq_pre_commenting' );
  2. function wpq_pre_commenting( $pid ) {
  3. $parent_id = filter_input( INPUT_POST, 'comment_parent', FILTER_SANITIZE_NUMBER_INT );
  4. $post = get_post( $pid );
  5. $cuid = get_current_user_id();
  6. if( ! is_null( $post ) && $post->post_author == $cuid && 0 == $parent_id ) {
  7. wp_die( 'Sorry, post author can only reply to a comment!' );
  8. }
  9. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement