term_updated_messagesfilter-hookWP 3.7.0

Allows you to change messages displayed when terms (categories, tags, and so on) are handled on their creation and editing pages.

By default, the filter receives the following array:

Array
(
	[_item] => Array
		(
			[0] =>
			[1] => Item added.
			[2] => Item deleted.
			[3] => Item updated.
			[4] => Item not added.
			[5] => Item not updated.
			[6] => Items deleted.
		)

	[category] => Array
		(
			[0] =>
			[1] => Category added.
			[2] => Category deleted.
			[3] => Category updated.
			[4] => Category not added.
			[5] => Category not updated.
			[6] => Categories deleted.
		)

	[post_tag] => Array
		(
			[0] =>
			[1] => Tag added.
			[2] => Tag deleted.
			[3] => Tag updated.
			[4] => Tag not added.
			[5] => Tag not updated.
			[6] => Tags deleted.
		)

)

Usage

add_filter( 'term_updated_messages', 'wp_kama_term_updated_messages_filter' );

/**
 * Function for `term_updated_messages` filter-hook.
 * 
 * @param array[] $messages Array of arrays of messages to be displayed, keyed by taxonomy name.
 *
 * @return array[]
 */
function wp_kama_term_updated_messages_filter( $messages ){
	// filter...
	return $messages;
}
$messages(array)
The messages to be displayed.

Examples

#1 Change the "Category updated" message

add_filter( 'term_updated_messages', 'change_term_updated_messages' );

function change_term_updated_messages( $messages ) {
	$messages['category'][3] = 'This wonderful category has been updated';

	return $messages;
}

#2 Change the message when a WooCommerce term is updated

By default, "Item updated" is displayed, but the term_updated_messages hook lets us replace it with a custom message, for example, "Term ‘{attribute name}’ updated."

add_filter( 'term_updated_messages', 'wc_term_updated_messages' );

function wc_term_updated_messages( $messages ) {
	global $post_type, $tag;

	if ( 'product' === $post_type && $tag ) {
		$messages['_item'][3] = "Term ‘{$tag->name}’ updated.";
	}

	return $messages;
}

Changelog

Since 3.7.0 Introduced.

Where the hook is called

In file: /wp-admin/includes/edit-tag-messages.php
term_updated_messages
wp-admin/includes/edit-tag-messages.php 49
$messages = apply_filters( 'term_updated_messages', $messages );

Where the hook is used in WordPress

Usage not found.