钩子文档

added_{$meta_type}_meta

💡 云策文档标注

概述

added_{$meta_type}_meta 是一个 WordPress 动作钩子,在特定类型的元数据添加后立即触发。它用于在元数据成功添加时执行自定义代码。

关键要点

  • 钩子名称是动态的,$meta_type 指代元对象类型,如 blog、post、comment、term、user 等。
  • 触发时机:在 add_metadata() 函数末尾调用。
  • 参数包括:$mid(元数据 ID)、$object_id(对象 ID)、$meta_key(元数据键)、$_meta_value(元数据值)。
  • 常见钩子名称示例:added_blog_meta、added_post_meta、added_comment_meta、added_term_meta、added_user_meta。

📄 原文内容

Fires immediately after meta of a specific type is added.

Description

The dynamic portion of the hook name, $meta_type, refers to the meta object type (blog, post, comment, term, user, or any other type with an associated meta table).

Possible hook names include:

  • added_blog_meta
  • added_post_meta
  • added_comment_meta
  • added_term_meta
  • added_user_meta

Parameters

$midint
The meta ID after successful update.
$object_idint
ID of the object metadata is for.
$meta_keystring
Metadata key.
$_meta_valuemixed
Metadata value.

More Information

This hook is called at the end of add_metadata() function.

Source

do_action( "added_{$meta_type}_meta", $mid, $object_id, $meta_key, $_meta_value );

Changelog

Version Description
2.9.0 Introduced.