0

I am working on wordpress comment section. I understand that when we are posting some comments for example comments with many links, then WordPress storing this comment in to the database with unapproved status. As the result in the website admin comment section, we can see that these comments are coming as unapproved (red background color.).

I want to know which function wordpress uses for this. And I want to use that function inside my custom code so that before saving it to database I can decide whether to store this comment or not.

I know how to prevent the post of comments before it gets to the database.

function preprocess_comment_spam( $commentdata ) {

    $spamwords = array( 'href', '[url', 'spamword' );

    foreach( $spamwords as $spam ) {

        if ( \strpos( $commentdata['comment_content'], $spam ) !== false ) {
            wp_die('Sorry, we detected some spam.'); // This is the Error Notice for Wordpress.
            /*return new WP_Error( 'spam_detected', __( 'Sorry, we detected some spam.' ), 403 );*/
        }
    }

    return $commentdata;
}
add_filter( 'preprocess_comment' , 'preprocess_comment_spam' );

But I want to know which WordPress default function that make a comment's as unapproved.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.