The create category wizard works great and I was able to add custom fields to my newly created categories. I’m trying to build a wizard to add these custom fields to existing categories.

I’m stuck because I tried to create an API called “add to category” with endpoint “update category” and at the end of my wizard for “add field to category” I have the action item “send to API” and I chose the correct endpoint in theory. I also added what should be the JSON payload: {“new_field”: w{step1_field1}} but I can’t save the wizard. It tells me “api_body is invalid”

What should go in the “API body” text area?

Another question I have is because one of the fields I have in this particular wizard is “category” field. It produces a text box to search and add existing categories.

How do I send this wizard value to my API to tell it what “id” to add to the endpoint?

right now I just have it as {id}
I know this is wrong but I’m trying to figure it out. If someone could help me understand this better I’d be happy to contribute towards making more useful wizards.

Use Case

This could enable users and moderators to add new fields to existing categories or change the value of keys that aren’t easily accessible in the edit category page.



One more thing. I noticed that after creating a new category with my custom fields, the show.json for all the existing categories have a null value for those fields.

Would it be possible, easier and/or better to add the new custom fields to the edit settings page for the group owner to make changes?

…edited later:
One more thing again. I’m just trying to figure this out and don’t have experience with discourse plugins but I was trying to use curl to update categories and got a “Bad CSRF”. So this led me down a rabbit hole. I can’t even update standard fields so this might not apply to the Custom Wizard Plugin but I came across a post which says editable custom fields need “register_editable_user_custom_field” and the plugin.rb for custom wizard doesn’t contain this.


We’ll discuss this one internally and get back to you.
cc @angus

1 Like