add comment from front side wordpress

Posted: June 5, 2015 in Uncategorized
Tags: , , , , ,

$commentdata = array(
‘comment_post_ID’ => $post_id, // to which post the comment will show up
‘comment_author’ => $current_user->user_login, //fixed value – can be dynamic
‘comment_author_email’ => $current_user->user_email, //fixed value – can be dynamic
‘comment_author_url’ => $current_user->user_url, //fixed value – can be dynamic
‘comment_content’ => $comment_text,//fixed value – can be dynamic
‘comment_type’ => ”, //empty for regular comments, ‘pingback’ for pingbacks, ‘trackback’ for trackbacks
‘comment_parent’ => 0, //0 if it’s not a reply to another comment; if it’s a reply, mention the parent comment ID here
‘user_id’ => $user_id, //passing current user ID or any predefined as per the demand
‘comment_approved’ => 0
);
$comment_id = wp_new_comment( $commentdata );
wp_set_comment_status( $comment_id, ‘hold’ );

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s