auth_post_meta_<meta_key>

Filters whether the user is allowed to add post meta to a post.

Description

apply_filters( 'auth_post_meta_<meta_key>', (bool) $false, (string) $meta_key, (int) $post_id, (int) $user_id, (string) $cap, (array) $caps ); 

The dynamic portion(s) of the hook name refer to the meta key passed to map_meta_cap().

Parameters (6)

0. $false (bool) => false
Whether the user can add the post meta. Default false.
1. $meta_key (string)
The meta key.
2. $post_id (int)
The post id.
3. $user_id (int)
The user id.
4. $cap (string)
Capability name.
5. $caps (array)
User capabilities.

Usage

To run the hook, copy the example below.
  1. $false = apply_filters( 'auth_post_meta_{$meta_key}', $false, $meta_key, $post_id, $user_id, $cap, $caps ); 
  2.  
  3. if ( !empty( $false ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the auth_post_meta_<meta_key> callback 
  2. function filter_auth_post_meta_meta_key( $false, $meta_key, $post_id, $user_id, $cap, $caps ) { 
  3. // make filter magic happen here... 
  4. return $false
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( "auth_post_meta_{$meta_key}", 'filter_auth_post_meta_meta_key', 10, 6 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( "auth_post_meta_{$meta_key}", 'filter_auth_post_meta_meta_key', 10, 6 ); 

Defined (1)

The filter is defined in the following location(s).

/wp-includes/capabilities.php  
  1. $allowed = apply_filters( "auth_post_meta_{$meta_key}", false, $meta_key, $post->ID, $user_id, $cap, $caps );