Title: Error while adding comment
Last modified: January 16, 2018

---

# Error while adding comment

 *  Resolved [jeromedms](https://wordpress.org/support/users/jeromedms/)
 * (@jeromedms)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/error-while-adding-comment/)
 * It seems there is a bug while adding comment :
 * The following call :
 * [https://www.mySite.com/api/user/post_comment?cookie=MyCookie&post_id=MyPostId&content=MyContent&comment_status=0](https://www.mySite.com/api/user/post_comment?cookie=MyCookie&post_id=MyPostId&content=MyContent&comment_status=0)
 * results in :
 * {“status”:”error”,”error”:”Please include ‘comment_status’ var in your request.
   Possible values are ‘1’ (approved) or ‘0’ (not-approved)”}
 * Because comment_status=0 is considered as a missing comment_status.
 * If I use instead :
 * [https://www.mySite.com/api/user/post_comment?cookie=MyCookie&post_id=MyPostId&content=MyContent&comment_status=’0&#8242](https://www.mySite.com/api/user/post_comment?cookie=MyCookie&post_id=MyPostId&content=MyContent&comment_status=’0&#8242);
 * The result is ok, but the comment never appears in the comments to moderate as
   it is stored in database with comment_status = “0” instead of 0
 * Could you please correct this issue ?

Viewing 10 replies - 1 through 10 (of 10 total)

 *  Thread Starter [jeromedms](https://wordpress.org/support/users/jeromedms/)
 * (@jeromedms)
 * [8 years, 3 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9869276)
 * The solution to make this working is to modify User.php as follow :
 *     ```
       if (!$json_api->query->comment_status ) {
         $json_api->error("Please include 'comment_status' var in your request. Possible values are '1' (approved) or '0' (not-approved)");
         }else $comment_approved = $json_api->query->comment_status;
       ```
   
 * modified :
 *     ```
       if (!isset($json_api->query->comment_status) ) {
         $json_api->error("Please include 'comment_status' var in your request. Possible values are '1' (approved) or '0' (not-approved)");
         }else $comment_approved = $json_api->query->comment_status;
       ```
   
 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9871813)
 * Thank you for pointing out the bug.
 * Plugin has been updated and current version 2.7 has updated post_comment endpoint.
 *  Thread Starter [jeromedms](https://wordpress.org/support/users/jeromedms/)
 * (@jeromedms)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9873301)
 * great, thanks
 *  Thread Starter [jeromedms](https://wordpress.org/support/users/jeromedms/)
 * (@jeromedms)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9889788)
 * I checked the V2.7 regarding this issue, and it still not work.
    It seems isset()
   still returns false if the variable is zero. After some research, It seems difficult
   to test a variable if it is zero.
 * I suggest the url should be comment_status=’0′ or comment_status=’1′ so the tests
   are easier, then, we updating database, cast to integer as follow :
 * $data = array(
    … … ‘comment_approved’ => (int) $comment_approved, );
 * I did not check this but I guess it should work.
    Thanks Jerome
 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9893384)
 * I will check this issue and test it thoroughly before making an update in couple
   of days.
 *  Thread Starter [jeromedms](https://wordpress.org/support/users/jeromedms/)
 * (@jeromedms)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9893511)
 * Thanks Ali.
 *  Thread Starter [jeromedms](https://wordpress.org/support/users/jeromedms/)
 * (@jeromedms)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9912917)
 * Hi Ali,
    Any news regarding this pending issue ? Thanks Jerome
 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9913222)
 * I have updated the plugin. version 2.8 has resolved this issue.
 * You can send comment_status=hold for unapproved comment and comment_status=1 
   for approved.
 *  Thread Starter [jeromedms](https://wordpress.org/support/users/jeromedms/)
 * (@jeromedms)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9914046)
 * great, it works now
 *  Plugin Author [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * (@parorrey)
 * [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9914102)
 * plz review the plugin and help others by rating.

Viewing 10 replies - 1 through 10 (of 10 total)

The topic ‘Error while adding comment’ is closed to new replies.

 * ![](https://ps.w.org/json-api-user/assets/icon-256x256.png?rev=1965790)
 * [JSON API User](https://wordpress.org/plugins/json-api-user/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/json-api-user/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/json-api-user/)
 * [Active Topics](https://wordpress.org/support/plugin/json-api-user/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/json-api-user/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/json-api-user/reviews/)

 * 10 replies
 * 2 participants
 * Last reply from: [Ali Qureshi](https://wordpress.org/support/users/parorrey/)
 * Last activity: [8 years, 2 months ago](https://wordpress.org/support/topic/error-while-adding-comment/#post-9914102)
 * Status: resolved