There is a dynamic hook right before any new metadata is added:
do_action( "add_{$meta_type}_meta", $object_id, $meta_key, $_meta_value );
It would be add_post_meta
for posts accordingly.
Note that you might to tinker some to catch this precisely in the case of new post being created, for example hook into publish_post
first, note the ID, and add to this hook from there.
Related Posts:
- Is there a way to set default custom fields when creating a post?
- Is there any action filter/hook for validating a custom field before publishing the post?
- Add subtitle to Woocommerce product title
- getEntityRecord without knowing the post type
- Get updated meta data after save_post hook
- Check before publishing, if already exist post with current custom field value
- post meta data clearing on autosave
- Display info from custom fields in all images’ HTML
- Using custom fields in a filter hook
- Update meta values with AJAX
- Registration and Profile custom field
- How to update a meta field of type array in Gutenberg
- Send email with custom fields after new draft is saved or new post published
- Can’t save custom field on registration page
- Best Way to get facebook share count and update using wp_schedule_event or any other method
- No result update a custom field using wp_schedule_event
- Using Custom Fields to Trigger Specific Actions on Saving a Post?
- Why isn’t update_post_meta saving?
- change attachment custom field onChange event
- Change event firing in wordpress
- Incorrect data after modifying post using backlink from wp_die
- How to automatically create a custom field when a post is published?
- Add custom fields to specific menus
- Set new url from custom post field
- Is it safe to store a user setting you don’t want the user to ever modify as a user option?
- extend Meta Box / Document Panel
- Add multiple images to a page sidebar
- How to delete custom field “suggestions” from dropdown list
- Add custom field to image editor
- How to load php file for specific page in admin?
- How to set default metaboxes on user creation?
- Metabox nonce PHP notice
- ajax jquery update custom field meta value front end
- How to break meta values into different items and avoid duplicates?
- ajax delete value from custom field array
- Add input field to ‘Pages > Edit Page’ through functions.php
- How can I query on the year part of a complete date in a custom field?
- WordPress Custom Field Should be Unique. Is it possible?
- How to display Meta Field Value?
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- What is the cleanest way to extract custom variables from a post
- Add source URL from Feed WordPress (Syndication) plugin to a custom field in post editor
- Order query by meta_value with multiple custom fields
- How do I create a column in Users list and display user data from custom registration field
- Display only past events on that page using Visual Composer Grid Bulider
- user Profile meta value as custom field
- Remove Body Classes
- Use WPbakery for own custom field [closed]
- Add custom field to all posts in specific post_type
- Change the sort order for posts to include custom field
- Button inside Custom Meta Box triggering the Update Button
- Get Data From wp_sitemeta for Multisite network
- Allow only one post with specific meta value
- Attach images to posts using custom fields (just paths to images already uploaded)
- how to display custom fields of post on a web page
- Changed PHP handler to DSO – weird custom fields problem [closed]
- How to fill custom fields with brackets in their key with add_post_meta()?
- Is there a way to set default custom fields when creating a new post?
- Front-End User Profile
- Add custom column for custom field
- ul list with only as many li’s as filled custom fields
- Is there a way to dump all registered sidebar/widget?
- put saved metabox values back into fields and then display on the front end
- How to hide post meta
- Custom field to array?
- How to sort by custom field value?
- Meta Box Plugin Cloned Fields – Multiple Foreach values
- get_post_meta returns 0
- How to query posts by month based on date custom field?
- Custom field bug in WordPress 3.2
- get posts based on non-single metadata
- Problem with revisions only returning four results
- How to save multiple values with same meta_key, each value linked to another tag id
- Add forms dynamically in admin pages?
- Let any visitors delete a post if they know Id nr & password?
- What WordPress “technology” would I use if I wanted subscribers to be able to mark pages with characteristics and notes?
- how can i show WordPress custom field data to my short code?
- update a custom field with the value of another existing custom field
- searching by keywords in post’s metas or pagination links problem
- Permanently show Custom Fields in Editor
- open modal window
- a lot of custom fields
- Hide custom fields by user’s role
- Ordering posts by custom fields (Date)
- update meta field value after
- PHP and Shortcode Combination
- If metabox fields has content display content
- Custom fields and auto save
- Save values generated via API as custom meta fields
- WP Query multiple select form – meta_query help
- Load code for custom fields only on admin pages?
- Custom field in a shortcode?
- Exclude empty fields from custom field calculation (Average)
- How to create Parent-Child relation for custom fields?
- How to check if custom field exists in this widget query
- display loop only if a post meta data exist
- How do i output images from URL’s added to the same custom field key
- Add Custom field under the post title [closed]
- Filter Query Post by Custom Fields(by date)
- Can’t sort custom column on user.php by number / meta_value_num?