How can I use WordPress hooks for categories in Amelia
Amelia provides several hooks related to categories, allowing you to modify category data or run custom actions when categories are added, updated, retrieved, or deleted. These hooks help you extend Amelia safely without adjusting core plugin files.
Hooks require programming knowledge, and support is limited to general guidance.
Category added
How do I modify category data before it is added?
amelia_before_category_added_filter
Type: filter
Use this filter to modify category data before it is added.
function example($category)
{
// change category data
return $category;
}
add_filter('amelia_before_category_added_filter', 'example', 10, 1);
How do I run code before a category is added?
amelia_before_category_added
Type: action
Runs before a category is added.
function example($category)
{
// do action
}
add_action('amelia_before_category_added', 'example', 10, 1);
How do I run code after a category is added?
amelia_after_category_added
Type: action
Runs after a category is added.
function example($category)
{
// do action
}
add_action('amelia_after_category_added', 'example', 10, 1);
Category updated
How do I modify category data before it is updated?
amelia_before_category_updated_filter
Type: filter
Use this filter to modify category data before it is updated.
function example($category)
{
// change category data
return $category;
}
add_filter('amelia_before_category_updated_filter', 'example', 10, 1);
How do I run code before a category is updated?
amelia_before_category_updated
Type: action
Runs before a category is updated.
function example($data)
{
// do action
}
add_action('amelia_before_category_updated', 'example', 10, 1);
How do I run code after a category is updated?
amelia_after_category_updated
Type: action
Runs after a category is updated.
function example($data)
{
// do action
}
add_action('amelia_after_category_updated', 'example', 10, 1);
Get categories
How do I modify categories before they are retrieved?
amelia_get_categories_filter
Type: filter
Use this filter to modify categories before they are retrieved for the back end.
function example($categories)
{
return $categories;
}
add_filter('amelia_get_categories_filter', 'example', 10, 1);
How do I run code before categories are retrieved?
amelia_get_categories
Type: action
Runs before categories are retrieved for the back end.
function example($categories)
{
// do action
}
add_action('amelia_get_categories', 'example', 10, 1);
Get category
How do I modify a category before it is retrieved?
amelia_get_category_filter
Type: filter
Use this filter to modify category data before it is retrieved for the back end.
function example($category)
{
return $category;
}
add_filter('amelia_get_category_filter', 'example', 10, 1);
How do I run code before a category is retrieved?
amelia_get_category
Type: action
Runs before a category is retrieved for the back end.
function example($category)
{
// do action
}
add_action('amelia_get_category', 'example', 10, 1);
Category deleted
How do I run code before a category is deleted?
amelia_before_category_deleted
Type: action
Runs before a category is deleted.
function example($category)
{
// do action
}
add_action('amelia_before_category_deleted', 'example', 10, 1);
How do I run code after a category is deleted?
amelia_after_category_deleted
Type: action
Runs after a category is deleted.
function example($category)
{
// do action
}
add_action('amelia_after_category_deleted', 'example', 10, 1);