Filter hook 'get_usernumposts'

in WP Core File wp-includes/user.php at line 645

View Source

get_usernumposts

Filter Hook
Description
Filters the number of posts a user has written.

Hook Information

File Location wp-includes/user.php View on GitHub
Hook Type Filter
Line Number 645

Hook Parameters

Type Name Description
int $count The user's post count.
int $userid User ID.
string|array $post_type Single post type or array of post types to count the number of posts for.
bool $public_only Whether to limit counted posts to public posts.

Usage Examples

Basic Usage
<?php
// Hook into get_usernumposts
add_filter('get_usernumposts', 'my_custom_filter', 10, 4);

function my_custom_filter($count, $userid, $post_type, $public_only) {
    // Your custom filtering logic here
    return $count;
}

Source Code Context

wp-includes/user.php:645 - How this hook is used in WordPress core
<?php
 640  	 * @param int          $count       The user's post count.
 641  	 * @param int          $userid      User ID.
 642  	 * @param string|array $post_type   Single post type or array of post types to count the number of posts for.
 643  	 * @param bool         $public_only Whether to limit counted posts to public posts.
 644  	 */
 645  	return apply_filters( 'get_usernumposts', $count, $userid, $post_type, $public_only );
 646  }
 647  
 648  /**
 649   * Gets the number of posts written by a list of users.
 650   *

PHP Documentation

<?php
/**
	 * Filters the number of posts a user has written.
	 *
	 * @since 2.7.0
	 * @since 4.1.0 Added `$post_type` argument.
	 * @since 4.3.1 Added `$public_only` argument.
	 *
	 * @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.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 4
  • File: wp-includes/user.php
Related Hooks

Related hooks will be displayed here in future updates.