A backend event that fires when a new forum category is created.
The onCategoryCreated()
event handler runs when a new forum category is created in your site.
The received CreatedCategory
object contains information about the new category that was created.
Notes:
If you create a category from your published site, onCategoryCreated()
runs only when you finish defining the settings and click Create. If you create a category using the forum settings in the Editor, onCategoryCreated()
will run with the default settings as soon as you click Add New Category. As you continue to define the category settings, onCategoryUpdated()
will run.
Backend events are not fired when previewing your site.
function onCategoryCreated(event: CreatedCategory): void;
Information about the forum category that was created.
In this example, the category header background is a color.
// Place this code in a file named events.js
// in the Backend section of your code files.
export function wixForum_onCategoryCreated(event) {
const categoryId = event.categoryId;
const categoryName = event.category.name;
}
/* Full category object:
* {
* "_id": "5f88058be9b6b100175b154d",
* "name": "My Category Name",
* "headerTitle": "My Category Header Title",
* "description": "This is a description of my category.",
* "headerType": "COLOR",
* "headerBackgroundColor": {
* "color": "#8F98E2",
* "opacity": 0.5
* },
* "headerTextColor": {
* "color": "#9E3B1B",
* "opacity": 1
* },
* "rank": 2,
* "slug": "my-category-name",
* "pageUrl": "/forum/my-category-name",
* "postCount": 0,
* "postViewCount": 0,
* "writeProtected": "false",
* "_createdDate": "2020-10-26T07:18:20.297Z",
* "_updatedDate": "2020-10-26T07:18:20.297Z"
* }
*/
This method doesn’t return any custom errors, but may return standard errors. Learn more about standard Wix errors.