Opens in a new tab
A picture of Jeff Brigman
I CODE TODAY FOR
A BETTER TOMORROW

Glossary Term

wp_new_comment()

3 tags 1 category

wp_new_comment() — Adds a new comment to the database. Filters new comment to ensure that the fields are sanitized and valid before inserting comment into database. Calls ‘comment_post’ action with comment ID and whether comment is approved by WordPress. Also has ‘preprocess_comment’ filter for processing the comment data before the function handles it. We use REMOTE_ADDR here directly. If you are behind a proxy, you should ensure that it is properly set, such as in wp-config.php, for your environment. See https://core.trac.wordpress.org/ticket/9235

Inputs: $commentdata (array): Comment data. Field $comment_author (string): The name of the comment author. Field $comment_author_email (string): The comment author email address. Field $comment_author_url (string): The comment author URL. Field $comment_content (string): The content of the comment. Field $comment_date (string): The date the comment was submitted. Default is the current time. Field $comment_date_gmt (string): The date the comment was submitted in the GMT timezone. Default is $comment_date in the GMT timezone. Field $comment_type (string): Comment type. Default ‘comment’. Field $comment_parent (int): The ID of this comment’s parent, if any. Default 0. Field $comment_post_ID (int): The ID of the post that relates to the comment. $wp_error (bool): Should errors be returned as WP_Error objects instead of executing wp_die()? Default false.

Returns int|false|WP_Error: The ID of the comment on success, false or WP_Error on failure.

Term Connections

Explore related terms connected by shared tags, shared categories, and relationship phrases. This map loads only when it comes into view.

Loading term connections…