update_{$meta_type}_meta
云策文档标注
概述
update_{$meta_type}_meta 是一个 WordPress 钩子,在更新特定类型的元数据前立即触发。它允许开发者在元数据更新过程中执行自定义操作。
关键要点
- 钩子名称是动态的,$meta_type 指代元对象类型,如 blog、post、comment、term、user 等。
- 参数包括 $meta_id(元数据条目ID)、$object_id(对象ID)、$meta_key(元数据键)和 $_meta_value(元数据值)。
- 相关函数有 update_metadata_by_mid() 和 update_metadata(),用于通过元ID或对象更新元数据。
注意事项
- 此钩子自 WordPress 2.9.0 版本引入,适用于需要拦截或修改元数据更新流程的场景。
原文内容
Fires immediately before updating metadata of a specific type.
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:
update_blog_metaupdate_post_metaupdate_comment_metaupdate_term_metaupdate_user_meta
Parameters
$meta_idint-
ID of the metadata entry to update.
$object_idint-
ID of the object metadata is for.
$meta_keystring-
Metadata key.
$_meta_valuemixed-
Metadata value.
Source
do_action( "update_{$meta_type}_meta", $meta_id, $object_id, $meta_key, $_meta_value );
Changelog
| Version | Description |
|---|---|
| 2.9.0 | Introduced. |