wp_insert_comment [ WordPress Function ]
wp_insert_comment ( $commentdata )
| Parameters: |
|
| Uses: |
|
| Returns: |
|
| Defined at: |
|
Similar Functions: wp_list_comments, wp_new_comment, wp_filter_comment, wp_insert_attachment, wp_insert_post
Inserts a comment to the database.
The available comment data key names are 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_parent', 'comment_approved', and 'user_id'.
Source
<?php
function wp_insert_comment($commentdata) {
global $wpdb;
extract(stripslashes_deep($commentdata), EXTR_SKIP);
if ( ! isset($comment_author_IP) )
$comment_author_IP = '';
if ( ! isset($comment_date) )
$comment_date = current_time('mysql');
if ( ! isset($comment_date_gmt) )
$comment_date_gmt = get_gmt_from_date($comment_date);
if ( ! isset($comment_parent) )
$comment_parent = 0;
if ( ! isset($comment_approved) )
$comment_approved = 1;
if ( ! isset($comment_karma) )
$comment_karma = 0;
if ( ! isset($user_id) )
$user_id = 0;
if ( ! isset($comment_type) )
$comment_type = '';
$data = compact('comment_post_ID', 'comment_author', 'comment_author_email', 'comment_author_url', 'comment_author_IP', 'comment_date', 'comment_date_gmt', 'comment_content', 'comment_karma', 'comment_approved', 'comment_agent', 'comment_type', 'comment_parent', 'user_id');
$wpdb->insert($wpdb->comments, $data);
$id = (int) $wpdb->insert_id;
if ( $comment_approved == 1 )
wp_update_comment_count($comment_post_ID);
$comment = get_comment($id);
do_action('wp_insert_comment', $id, $comment);
return $id;
}
?>
Examples [ wp-snippets.com ]
Top Google Search Results
- Function Reference/wp insert comment « WordPress Codex
Description. Inserts a comment to the database. The available $commentdata key names are 'comment_author_IP', 'comment_date', 'comment_date_gmt', ...
codex.wordpress.org - comments - How to override wp_insert_comment() - WordPress
May 18, 2012 ... I am trying to override wp_insert_comment() (wp-includes/comment.php). I added the following lines of code in my functions.php file, located in ...
wordpress.stackexchange.com - wp_insert_comment (WordPress Function) - WPSeek.com
WordPress lookup for wp_insert_comment, a WordPress Function. wpseek.com is a WordPress-centric search tool for developers and theme authors.
wpseek.com - php - Wordpress inserting comments via wp_insert_comment ...
I don't think Disqus imports comments from the WordPress database in real-time. If you wanted it to appear in Disqus' database immediately, you'd ...
stackoverflow.com