Frank Vèssia Posted February 26, 2015 Share Posted February 26, 2015 I'm trying to set a comment status when posting new comment via API but pw set to 1 even I set to -2 or 0. Am I missing something?I tried to play with some options in admin, like activating akismet, or quite save... with no luck. I'm using PW dev 2.5.19 $text = $sanitizer->text($input->post->txt); $root = $pages->get("template=member,userlink=$user"); $c = new Comment(); $c->text = $text; $c->cite = $user->name; $c->created = time(); $c->email = $user->email; $c->user_agent = $_SERVER['HTTP_USER_AGENT']; $c->ip = $_SERVER['REMOTE_ADDR']; $c->created_users_id = $user->id; $c->sort = count($root->comments)+1; $c->status = -2; // just for testing $root->of(false); $root->comments->add($c); if($root->save()){ $root->of(true); print "success"; } Link to comment Share on other sites More sharing options...
renobird Posted February 26, 2015 Share Posted February 26, 2015 Seems like the moderation setting for the comments field is overriding your setting. Does adding this way make any difference?$root->comments->add = $c; Link to comment Share on other sites More sharing options...
Frank Vèssia Posted February 26, 2015 Author Share Posted February 26, 2015 Tried, no differences, comment published with status 1. Link to comment Share on other sites More sharing options...
renobird Posted February 26, 2015 Share Posted February 26, 2015 Does the status change to something other than 1 if you change the moderation settings for the field? Link to comment Share on other sites More sharing options...
Frank Vèssia Posted February 26, 2015 Author Share Posted February 26, 2015 Yes, if I set to "comments must be approved..." the status is set to 0 (pending). It's like you said, the moderation settings are overriding the api settings. Link to comment Share on other sites More sharing options...
renobird Posted February 26, 2015 Share Posted February 26, 2015 I can confirm this here. I've always set $c->status = 1, so I never noticed that it's not actually working correctly. Looking at comment.php, I thought perhaps setting $c->status = $c->statusSpam might do it, but still saves as 1 in the DB. 1 Link to comment Share on other sites More sharing options...
Frank Vèssia Posted February 27, 2015 Author Share Posted February 27, 2015 If I want to add more statuses like 2,3,4 etc..., do you suggest an hook (if possible) or creating a duplicate of comments module and add statuses directly to the module? Link to comment Share on other sites More sharing options...
adrian Posted March 21, 2015 Share Posted March 21, 2015 Hey did you guys ever sort this out - looks to me like it is still impossible to set the status via the API - it still reverts back to what the moderation settings enforce. I think I'll post a Github issue! Link to comment Share on other sites More sharing options...
Frank Vèssia Posted March 21, 2015 Author Share Posted March 21, 2015 I created my own "comment" module at the end... 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now