you are not counting the post author always and if it's also a commenter then don't count.
i am not counting the post author because of your request:
'Now I want to count unique users who have participated in the post, I mean, unique commenters + 1 (post author). But what happen if the post author is also a commenter?' - if this is not what you meant, please clarify.
- initially the post users are the author + commenters
the code is not outputting post users, but post commenters which are not the post author. i.e. the post author is never counted - neithre if he commented on his own post, nor if has not commented.
if you want to show the number 1 if nobody has commented so far, or the only commenter is the post author, the add 1 to the result of the code.
you can avoid the warning by adding a conditional statement
<?php $comms = get_comments('post_id='.$post->ID);
foreach( $comms as $comm ) {
if( $comm->user_id != $post->post_author ) $comm_authors[] = $comm->comment_author; }
if( $comm_authors$ ) : //avoid error warning if no comments
unique_comm_authors = array_unique($comm_authors); endif;
echo 'unique commenters: '.count($unique_comm_authors);
?>