Wordpress inserting comments via wp_insert_comment()
- by Cyber Junkie
Hello all happy holidays! :)
I'm trying to insert comments in my wordpress blog via the wp_insert_comment() function. It's for a plugin I'm trying to make.
I have this code in my header for testing. It works every time I refresh the page.
$agent = $_SERVER['HTTP_USER_AGENT'];
$data = array(
'comment_post_ID' => 256,
'comment_author' => 'Dave',
'comment_author_email' => '[email protected]',
'comment_author_url' => 'http://www.someiste.com',
'comment_content' => 'Lorem ipsum dolor sit amet...',
'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,
);
$comment_id = wp_insert_comment($data);
It successfully inserts comments into the database.
The problem: Comments don't show via the Disqus comment system. I compared table rows and I noticed that user_agent differs.
Normal comments use for example, Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv...
and Disqus comments use Disqus/1.1(2.61):119598902 numbers are different for each comment.
Does anyone know how to insert comments with wp_insert_comment() when Disqus is enabled?