onCategoryCreated( )
A backend event that fires when a new forum category is created.
Description
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.
Syntax
function onCategoryCreated(event: CreatedCategory): void
onCategoryCreated Parameters
NAME
TYPE
DESCRIPTION
Information about the forum category that was created.
Returns
This function does not return anything.
Return Type:
Was this helpful?
In this example, the category header background is a color.
1// Place this code in a file named events.js2// in the Backend section of your code files.34export function wixForum_onCategoryCreated(event) {5 const categoryId = event.categoryId;6 const categoryName = event.category.name;7}89/* Full category object:10 * {11 * "_id": "5f88058be9b6b100175b154d",12 * "name": "My Category Name",13 * "headerTitle": "My Category Header Title",14 * "description": "This is a description of my category.",15 * "headerType": "COLOR",16 * "headerBackgroundColor": {17 * "color": "#8F98E2",18 * "opacity": 0.519 * },20 * "headerTextColor": {21 * "color": "#9E3B1B",22 * "opacity": 123 * },24 * "rank": 2,25 * "slug": "my-category-name",26 * "pageUrl": "/forum/my-category-name",27 * "postCount": 0,28 * "postViewCount": 0,29 * "writeProtected": "false",30 * "_createdDate": "2020-10-26T07:18:20.297Z",31 * "_updatedDate": "2020-10-26T07:18:20.297Z"32 * }33 */34
In this example, the category header background is an image.
1// Place this code in a file named events.js2// in the Backend section of your code files.34export function wixForum_onCategoryCreated(event) {5 const categoryId = event.categoryId;6 const categoryName = event.category.name;7}89/* Full category object:10 * {11 * "_id": "5f88058be9b6b100175b154d",12 * "name": "My Category Name",13 * "headerTitle": "My Category Header Title",14 * "description": "This is a description of my category.",15 * "headerType": "IMAGE",16 * "headerImage": "wix:image://v1/a27d24_3...46~mv2.jpg/_.jpg#originWidth=940&originHeight=529",17 * "headerImageOverlayColor": {18 * "color": "#40E0D0",19 * "opacity": 0.120 * },21 * "rank": 2,22 * "slug": "my-category-name",23 * "pageUrl": "/forum/my-category-name",24 * "postCount": 0,25 * "postViewCount": 0,26 * "writeProtected": "true",27 * "_createdDate": "2020-10-26T07:18:20.297Z",28 * "_updatedDate": "2020-10-26T07:18:20.297Z"29 * }30 */31