use "pre_option_require_name_email" filter instead of "check_comment_flood"

thanks @akirk
This commit is contained in:
Matthias Pfefferle 2020-12-18 17:36:07 +01:00
parent e7c0526103
commit 5d7ad7f4b2

View file

@ -302,16 +302,12 @@ class Inbox {
), ),
); );
// disable flood control
\remove_action( 'check_comment_flood', 'check_comment_flood_db', 10 );
// do not require email for AP entries // do not require email for AP entries
add_filter( 'pre_option_require_name_email', '__return_false' ); \add_filter( 'pre_option_require_name_email', '__return_false' );
$state = \wp_new_comment( $commentdata, true );
remove_filter( 'pre_option_require_name_email', '__return_false' );
// re-add flood control $state = \wp_new_comment( $commentdata, true );
\add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 );
\remove_filter( 'pre_option_require_name_email', '__return_false' );
} }
/** /**
@ -338,15 +334,11 @@ class Inbox {
), ),
); );
// disable flood control
\remove_action( 'check_comment_flood', 'check_comment_flood_db', 10 );
// do not require email for AP entries // do not require email for AP entries
add_filter( 'pre_option_require_name_email', '__return_false' ); \add_filter( 'pre_option_require_name_email', '__return_false' );
$state = \wp_new_comment( $commentdata, true );
remove_filter( 'pre_option_require_name_email', '__return_false' );
// re-add flood control $state = \wp_new_comment( $commentdata, true );
\add_action( 'check_comment_flood', 'check_comment_flood_db', 10, 4 );
\remove_filter( 'pre_option_require_name_email', '__return_false' );
} }
} }