#19: delete_{$meta_type}_metadata

The delete_{$meta_type}_metadata dynamic filter effectively allows you to prevent certain meta data from being deleted. The dynamic $meta_type variable accepts ‘user’, ‘comment’, or ‘post’.

It is evaluated in delete_metadata() in the wp-includes/meta.php file.

delete_{$meta_type}_metadata accepts 5 arguments:

  1. bool null If anything other than null is returned, delete_metadata() will short-circuit and return the boolean equivalent of that value. Default return for delete_metadata() is true on successful delete, false on failure
  2. int $object_id The user, comment or post object id
  3. string $meta_key The meta key to delete
  4. string $meta_value The meta value to delete
  5. bool $delete_all Whether to ignore $object_id further down in delete_metadata(). Default is false


Let’s say you want to keep non-admin users from deleting featured images once they’re set (for some reason). The following uses the dynamic delete_post_metadata hook accomplish this.

View the code example on Gist.

#3: wpmu_signup_user_notification

The wpmu_signup_user_notification filter is used in a boolean — or true/false — capacity to determine whether a confirmation email should be sent for new user signups in Multisite. It defaults to true.

It is evaluated in its namesake function, wpmu_signup_user_notification(), located in wp-includes/ms-functions.php.

The filter accepts four arguments:

  1. string $user The user’s login name
  2. string $user_email The user’s email
  3. string $key The activation key from wp_signup_user()
  4. array $meta By default, an empty array

If $user is not empty, the filter returns a value of true. Core uses the filter in just this capacity to disable sending a signup email when the ‘Skip Confirmation Email’ checkbox is selected on the Users > Add New screen.


Let’s say we only want to disable the user confirmation email for users who don’t have a Gmail address. We’ll test the user email for signs of Gmail and return false if we find it.