Switch language

wpseek.com
Eine auf WordPress spezialiserte Suchmaschine für Entwickler und Theme-Autoren




wp_insert_comment [ WordPress Function ]

wp_insert_comment ( $commentdata )
Parameter:
  • (array) $commentdata Contains information on the comment.
Nutzt:
  • $wpdb
Gibt zurück:
  • (int) The new comment's ID.
Definiert in:



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 == )
        
wp_update_comment_count($comment_post_ID);

    
$comment get_comment($id);
    
do_action('wp_insert_comment'$id$comment);

    return 
$id;
}
?>

Beispiele [ wp-snippets.com ]

Top Google Suchergebnisse

Mehr ...

Nutzerduskussionen [ wordpress.org ]

0 Nutzerkommentare

Noch keine. Sei der Erste!

Neu hinzufügen ...



HTML5 Powered with CSS3 / Styling, Performance & Integration, and Semantics