Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.
Options

How to add custom data to Discussion API

I read this https://docs.vanillaforums.com/help/apiv2/swagger/#/Discussions/get_discussions
I want add more data to API result, such as 'body_excerpt'. How to inject custom data into API result?

Comments

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    Man, thanks for that question - it made me learn something new! But the answer to your question is quite conventional: you need a custom plugin for that.
    It doesn't have to be complicated, though. It only needs to have one one method:

        public function discussionsApiController_getOutput_handler($result) {
            $result['body_excerpt'] = Gdn_Format::excerpt(
                $result['body'],
                $result['format']
            );
            return $result;
        }
    
Sign In or Register to comment.