I am returning with another request of adjustment. Currently, this awards points to Content Author (author of post). So basically the author gets points for commenting on their own post.
Is there a possibility to check if the commenter is the author of post, and if so, skip/don’t award?
Here is the complete code that I use:
if ( function_exists( 'mycred_add' ) ) {
add_action( 'comment_post', 'award_new_guest_comments', 10, 2 );
function award_new_guest_comments( $comment_id, $comment_status )
{
if ( $comment_status == '1' )
award_points_for_guest_comments( 'approved', '', $comment_id );
}
add_action( 'transition_comment_status', 'award_points_for_guest_comments', 10, 3 );
function award_points_for_guest_comments( $new_status, $old_status, $comment )
{
// Look for approved comments
if ( $new_status != 'approved' ) return;
// Grab the comment object in case it is not there
if ( !is_object( $comment ) )
$comment = get_comment( $comment );
// Ignore Pingbacks or Trackbacks
if ( !empty( $comment->comment_type ) ) return;
// Get post author
$post = get_post( (int) $comment->comment_post_ID );
$post_author = $post->post_author;
// Check if the post author should be excluded
if ( mycred_exclude_user( $post_author ) === true ) return;
// Award points to author
mycred_add(
'new_comment', // reference
$post_author, // who to get points
1, // number of points to award
'Guest comment on <a href=%c_post_url%>%c_post_title%</a>', // log template to use
$comment->comment_ID, // save comment id as reference id
array( 'ref_type' => 'comment' ) // enable support for comment related template tags
);
}
}