get_usernumposts

Filters the number of posts a user has written.

Description

apply_filters( 'get_usernumposts', (number) $count, (int) $userid, (string|array) $post_type, (bool) $public_only ); 

Parameters (4)

0. $count (number)
The user's post count.
1. $userid (int)
The userid.
2. $post_type (string|array)
Single post type or array of post types to count the number of posts for.
3. $public_only (bool)
Whether to limit counted posts to public posts.

Usage

To run the hook, copy the example below.
  1. $count = apply_filters( 'get_usernumposts', $count, $userid, $post_type, $public_only ); 
  2.  
  3. if ( !empty( $count ) ) { 
  4.  
  5. // everything has led up to this point... 
  6.  
  7.  
The following example is for adding a hook callback.
  1. // define the get_usernumposts callback 
  2. function filter_get_usernumposts( $count, $userid, $post_type, $public_only ) { 
  3. // make filter magic happen here... 
  4. return $count
  5. }; 
  6.  
  7. // add the filter 
  8. add_filter( 'get_usernumposts', 'filter_get_usernumposts', 10, 4 ); 
To remove a hook callback, use the example below.
  1. // remove the filter 
  2. remove_filter( 'get_usernumposts', 'filter_get_usernumposts', 10, 4 ); 

Defined (1)

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

/wp-includes/user.php  
  1. return apply_filters( 'get_usernumposts', $count, $userid, $post_type, $public_only );