Hey @kareswebdesign
I think I have sort of a solution for you.
One of the main problematic parts in the theme is this:
$comment = wp_handle_comment_submission( wp_unslash( $_POST ) );
if( is_wp_error( $comment ) ){
return $comment;
}
The $_POST variable contains the comment data and our honeypot, so it looks like this:
array(10) {
["c99fa3b100"]=> string(6) "TEST"
["comment"]=> string(0) ""
["action"]=> string(12) "post_comment"
["author"]=> string(16) "Torsten Testet"
["email"]=> string(24) "[email protected]"
["url"]=> string(0) ""
["comment_post_ID"]=> string(1) "1"
["comment_parent"]=> string(1) "0"
["_wpnonce"]=> string(10) "2e0c902dd2"
["submit"]=> string(0) ""
}
The new textarea is in “c99fa3b100” and the default “comment” is now our honeypot. If this comment field is filled out, the comment is marked as spam.
In your theme the comment gets submitted via wp_handle_comment_submission (as seen above) and in this core function there is a check for empty comments (you will recognize the error message!):
$allow_empty_comment = apply_filters( 'allow_empty_comment', false, $commentdata );
if ( '' === $comment_content && ! $allow_empty_comment ) {
return new WP_Error( 'require_valid_comment', __( 'Error: Please type your comment text.' ), 200 );
}
Unfortunately the variable $comment_content is filled before any filter is running, so it is empty, because it uses the default “comment” and not our new textarea (“c99fa3b100”) and without filter I can’t easily fix this.
Somehow we need to replicate (or repair) our honeypot check and switch those contents.
For details how to achieve this in general, see the tutorial for AJAX comments and my tutorial (in German) for adding ASB support.
After looking for an action hook for a long time, I decided to switch my approach and use a very early general hook (“init” in this case) and do my magic there. To limit the performance impact I leave the function if there is no comment context.
Here is the code:
https://gist.github.com/Zodiac1978/1d0f017a4486d917703eac4a8e4f5d0f
This allows back posting comments, but using wp_handle_comment_submission
still circumvents the preprocess_comment
filter and therefore every other check Antispam Bee is doing. But even if we will find a way to put this back somehow (maybe via manual call in the theme) there are still blocker in Antispam Bee (as mentioned from me in this re-opened issue: https://github.com/pluginkollektiv/antispam-bee/issues/149#issuecomment-1870265781).
Maybe the theme developer can help here too, so I ping @thesun2012 and I will have a look at the ASB side.
All the best
Torsten