How to trigger an action after a post is made

Unsolved Technical Support
  • I would like to trigger a specific action after a user submits a post. How would you recommend I do this?

    I found an old post that references "fireHook", how could I use that to my advantage?

    plugins.fireHook('action:post.purge', pid, function () { // all plugins are done });

    In my case I don't want to purge a post but rather do something else.

    Where would I even put the code chunk?

    Thanks.

  • @rod

    You can create a plugin that waits on the hook "action:post.save" and fires a method that executes the custom action you define

        { "hook": "action:post.save", "method": "customAction"  },
    

    Details on creating a plugin are available at Creating Plugins


Suggested Topics


  • How to post in chat room using API

    Unsolved Technical Support
    0 Votes
    1 Posts
    188 Views

    Hi there,

    I'm working on a script that interact with NodeBB using API. I need to create a new chat room between 2 users and post content in it. In the API documentation, there's some data concerning "Accessing a chat room" and "Getting a chat room", but in write api there's nothing at all.

    Is it currently impossible to post content in the chat room from the api?

    I'm using NodeBB v1.17.0.
    Api key created in admin panel. No problem to read chat room but writing failed.

    { "status": { "code": "not-found", "message": "Invalid API call" }, "response": {} }
  • 0 Votes
    1 Posts
    195 Views

    Re: Is there a way to bulk purge deleted posts?

    Same old topic, hoping there is a way now?

  • 1 Votes
    3 Posts
    249 Views

    Hi! @PitaJ thank you for the quick reply.
    I understand that an absolute URL have the protocol, but most of the normal users, at least in our forums, don't know what that is, some use it just because the copied from the browser, but sometimes a user doesn't add it, and having that links as relative URL returns a 404, causing a bad experience.
    Some CMS have a sanity check like Django and WordPress if you add a link inside a WordPress, they check if it's another domain and adds the protocol, so the user doesn't have to add it.
    I think it's a good measure to prevent bad user experience.

  • 0 Votes
    5 Posts
    1k Views

    @baris dude ! thank you very much, it work

  • 0 Votes
    6 Posts
    2k Views

    @psychobunny I guess it was happening because I changed the HTML structure, and Persona theme CSS uses > selectors, making the styles dependant on the HTML structure. Fixed now anyway thanks 🙂