This filter is applied before a metadata gets updated. For example if a user metadata gets updated the hook would be 'update_user_metadata'.
The filter must return null if the data should be saved to the database. If it returns anything else, the update_metadata (and therefore the update_user_meta) function will return what the filter returns.
See wp-includes/meta.php
, line 122 for more information on this.
function myplugin_init() { add_filter( 'update_user_metadata', 'myplugin_update_foo', 10, 5 ); } function myplugin_update_foo( $null, $object_id, $meta_key, $meta_value, $prev_value ) { if ( 'foo' == $meta_key && empty( $meta_value ) ) { return true; // this means: stop saving the value into the database } return null; // this means: go on with the normal execution in meta.php } add_action( 'init', 'myplugin_init' );
Since: 3.1
The update_(meta_type)_metadata hook is located in wp-includes/meta.php
, line 122