¿Cómo añadir datos adicionales de 'opts' al evento "DiscourseEvent.on(:post_created)" desde JavaScript?

I’ve tried this, but it was not completely successful. I’ll try to explain what I need this for exactly:

I’m making a plugin that will hide the original poster as soon as a post is created, but only if that option is enabled for that specific post. I have added a new button to the editor and that works fine. Toggling that button shows the variable named hide being set to true/false correctly, and the code you provided does work and “get” the value correctly.

However, it after pressing the button the variable changes, but the variable in your code does not get updated because it only updates once the editor is re-opened or the post is being edited. So I need a way to check the hide boolean variable value when the post is actually “saved” / “created”, allowing me to send that to the plugin.rb. And then in the plugin.rb it will check for that value and if that value is true, it will “hide” the original poster.
(that hiding the poster part all works if I add a check like this:

next unless opts[:raw].to_s.include? "<DontHidePost>"

but it doesn’t work when i try to do it like this:

next unless opts[:hide_post] == true

I hope this makes sense now.

If it helps I can pm you my plugin.rb file and my initializer file?

Edit: TL;DR:

  • I need the value of the variable/parameter to be “grabbed” and passed on at the very last moment when the post is being saved/created, instead of when the editor is being opened.
  • I need to be able to get the value of that variable in the plugin.rb file, which currently does not seem to work. The variable is getting passed on, and it’s available in .on(:post_created). It’s just the “old” value from when the editor was openend, not when it was changed after.

I appreciate all the help.