ecHo
asked 9 years ago

Hi, i want to use users question count(not total question) at my sites user profile page (using buddypress).. i can use total question count but i want Users questions, try too many suggest/function code for solved my problem but cant find any solution…

My site: http://kpssdelisi.com
User Profile Page Example: http://kpssdelisi.com/uyeler/kpssdelisi/

i try too many way like thats but cant solved my problem, if anyone have idea please tell

https://codex.wordpress.org/Function_Reference/count_user_posts

Usage

<?php $user_post_count = count_user_posts( $userid , $post_type ); ?>
<?php
function count_user_posts_by_type( $userid, $post_type = 'post' ) {
    global $wpdb;

    $where = get_posts_by_author_sql( $post_type, true, $userid );

    $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );

    return apply_filters( 'get_usernumposts', $count, $userid );
}
?>

this one use post type= dwqa-question but when try "-" show syntx error.. i change some different but still can’t solved..

http://wordpress.stackexchange.com/questions/43549/count-user-posts-by-user-id-post-type-and-post-status

use this one like;

function custom_get_user_posts_count($user_id,$args );  
    $args['author'] = $user;
    $args['fields'] = 'ids';
    $ps = get_posts($args);
    return count($ps);
}

by the way, i try this wordpress plugin
https://wordpress.org/plugins/users-custom-posts-counts/

thats work at backend / admin user list.. but i want to use at users profile page…

Any idea??

1 Answers
DominicStaff
answered 9 years ago

Hi,
Please send me username & password of your site (via private answer) for further checking.
Regards,

dumann78
replied 9 years ago

Thanks for reply but i solved my problem no need help anymore, thanks anyway..

Powered by DW Question & Answer Pro