XF 2.1 Setting a post as moderated to appear in the approvals list

HJW

Active member
Hi,

I'm writing a custom plugin to set a post as moderated.

Am I right to think that what I need to do is in xf_post the message_state=moderated and add to xf_spam_trigger_log: content_type=post and content_id=post.

Are there existing functions to do this (been looking but can't see any) or do I need to write new ones?
 
You want to update the message_state to moderated via post entity and it will automagically create a new record for the post in xf_approval_queue table.

Ah thanks so much, am I along the right lines with this? Doesn't seem to work but not sure how out I am :LOL:
Code:
               $postsFinder = \XF::app()->finder('XF:Post');
                $posts = $postsFinder->where('post_id', $result['post_id'])->fetch();

                foreach ($posts AS $post)
                {
                    /** @var \XF\Entity\Post $post */
                    $post->setOption('log_moderator', false);
                    $post->message_state = 'moderated';
                    $post->save();
                }
 
Top Bottom