ccc

Wordpress: Insertar un comentario desde una web externa

$agent = $_SERVER['HTTP_USER_AGENT'];
$arr = array(
    'comment_post_ID' => 10, // id del post
    'comment_author' => 'Pepe',
    'comment_author_email' => 'pepe@gmail.com',
    'comment_author_url' => 'http://www.pepe.com',
    'comment_content' => utf8_encode('En otro país multicolor nació una abeja bajo el sol'),
    'comment_author_IP' => '127.3.1.1',
    'comment_agent' => $agent,
    'comment_date' => date('Y-m-d H:i:s'),
    'comment_date_gmt' => date('Y-m-d H:i:s'),
    'comment_approved' => 1,
);
$id_coment = wp_insert_comment($arr);
if (is_wp_error($return)) {
    die($id_coment->get_error_message());
}
else {
    echo "Se inserto correctamente el comentario con el id: {$id_coment}";
}

No hay comentarios:

Publicar un comentario