get_usernumposts
Filters the number of posts a user has written.
Usage
add_filter( 'get_usernumposts', 'wp_kama_get_usernumposts_filter', 10, 4 ); /** * Function for `get_usernumposts` filter-hook. * * @param int $count The user's post count. * @param int $userid User ID. * @param string|array $post_type Single post type or array of post types to count the number of posts for. * @param bool $public_only Whether to limit counted posts to public posts. * * @return int */ function wp_kama_get_usernumposts_filter( $count, $userid, $post_type, $public_only ){ // filter... return $count; }
- $count(int)
- The user's post count.
- $userid(int)
- User ID.
- $post_type(string|array)
- Single post type or array of post types to count the number of posts for.
- $public_only(true|false)
- Whether to limit counted posts to public posts.
Changelog
Since 2.7.0 | Introduced. |
Since 4.1.0 | Added $post_type argument. |
Since 4.3.1 | Added $public_only argument. |
Where the hook is called
get_usernumposts
wp-includes/user.php 603
return apply_filters( 'get_usernumposts', $count, $userid, $post_type, $public_only );