Jump to content

set comment status


Frank Vèssia
 Share

Recommended Posts

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

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.

  • Like 1
Link to comment
Share on other sites

  • 4 weeks later...

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...