WordPress action hook · part of WordPress core

update_postmeta

A WordPress core action that 15 plugins also fire themselves, running on 203K+ sites between them.

“Fires immediately before updating a post's metadata.”

How to use update_postmeta

It's an action: your callback runs at that point and receives 4 arguments. Nothing needs to be returned. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_action( 'update_postmeta', function( $meta_id, $object_id, $meta_key, $meta_value ) {
	// Your code runs here.
}, 10, 4 );

Argument names come from WP Hide & Security Enhancer's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

This hook is fired by WordPress core too. Official reference on developer.wordpress.org →

15 plugins that fire update_postmeta

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. bbPress icon bbPress100,000+ installs do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $new_count ) includes/core/abstraction.php:355
  2. WP Hide & Security Enhancer icon WP Hide & Security Enhancer50,000+ installs do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ) include/wph.class.php:1730
  3. Directorist: AI-Powered Business Directory, Listings & Classified Ads icon Directorist: AI-Powered Business Directory, Listings & Classified Ads20,000+ installs do_action( 'update_postmeta', $meta_id, $id, $key, maybe_serialize( $replacement ) ) includes/cli/contact-fields.php:139
  4. WP Multilang icon WP Multilang10,000+ installs do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ) includes/abstracts/abstract-wpm-object.php:328
  5. 404 Solution: Redirection and Page Suggestions icon 404 Solution: Redirection and Page Suggestions10,000+ installs do_action( 'update_postmeta', $metaId, $postId, $key, $serializedValue ) includes/services/WordPressPostMutationNotifications.php:55
  6. Themify Builder icon Themify Builder6,000+ installs do_action( 'update_postmeta', $meta_id, $post_id, self::META_KEY, $builder ) classes/class-builder-data-manager.php:1140
  7. UpdraftCentral Dashboard icon UpdraftCentral Dashboard5,000+ installs do_action( 'update_postmeta', $meta_id, $object_id, $meta_key, $meta_value ) classes/site-meta.php:491
  8. SOOZ icon SOOZ2,000+ installs do_action( 'update_postmeta', $expected_meta_id, $attachment_post_id, $meta_key, $serialized_value ) includes/core/attachments-media.php:2966
  9. ProRank SEO icon ProRank SEO10+ installs do_action( 'update_postmeta', $meta_id, $post_id, $key, $stored_value ) includes/Modules/Content/InternalLinking/BuilderContentSupport.php:3142
  10. PerfLocale icon PerfLocaleFewer than 10 installs do_action( 'update_postmeta', $row['id'], $post_id, $key, $stored ) src/Translation/Fields/PostMetaStorage.php:97
  11. JonnyAD SEO icon JonnyAD SEOFewer than 10 installs do_action( 'update_postmeta', $meta_id, $post_id, $key, $to ) includes/admin.php:1457
  12. Dollar Pricing for WooCommerce icon Dollar Pricing for WooCommerceFewer than 10 installs do_action( 'update_postmeta', $meta_id, $post_id, $meta_key, $meta_value ) dolar-fiyatlandirma.php:69
  13. Sage Page Builder icon Sage Page BuilderFewer than 10 installs do_action( 'update_postmeta', $expected['meta_id'], $post_id, $layout_key, $encoded ) includes/class-layout-storage.php:218
  14. Baza Booking Calendar icon Baza Booking CalendarFewer than 10 installs do_action( 'update_postmeta', $meta_id, $post_id, $meta_key, $meta_value ) classes/class-bbc-booking-meta.php:389
  15. Klusio icon KlusioFewer than 10 installs do_action( 'update_postmeta', $mid, $id, $key, $nieuwDb ) klusio-builder-bridge.php:347

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.