Make WordPress Core

Ticket #44510: 44510.diff

File 44510.diff, 487 bytes (added by krynes, 6 years ago)

This is solution, the best option

  • user.php

     
    362362function count_user_posts( $userid, $post_type = 'post', $public_only = false ) {
    363363        global $wpdb;
    364364
     365        if( $userid === NULL AND !is_user_logged_in() ){
     366                return 0;
     367        }
     368
    365369        $where = get_posts_by_author_sql( $post_type, true, $userid, $public_only );
    366370
    367371        $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );