#1 WordPress forum plugin created by gVectors Team

wpForo – WordPress Forum Plugin
  • Home
  • Forum
  • Migrate to wpForo
  • Addons
  • Addons Demo
  • Documentation

Forum

Home | Forum

wpDiscuz - WordPress Comment Plugin
  • Forums
  • Members
  • Recent Posts
Forums
Main Support Forums
How-to and Troubles...
CPT added to total ...
 
Share:
Share
Tweet
Share
Notifications
Clear all

Script [Solved] CPT added to total blog articles in user activity

    Last Post
RSS

jarruego
Posts: 10
 jarruego
Topic starter
April 21, 2021 6:51 am
(@jarruego)
Active Member
Joined: 1 year ago

Hello

Is it possible that in user activity the custom post types are added to the total blog articles written by a user?

Thanks

 Screenshot_1.jpg
Topic Tags
user statistic profile statistic post count custom post type count blog posts
1 Reply
Robert
Posts: 9091
Robert - Twitter
 Robert
Admin
April 23, 2021 5:39 am
(@robert)
Support Team
Joined: 6 years ago

You should use this code. Put it in the functions.php file of your active WordPres theme or use the Code Snippets plugin to insert it into your website.

Don't forget to add custom post types in the $post_type = [....] array after the 'post'. Separate post types by comma, make sure you use the post type name not the post type titles. Post type names don't have upper case chars and spaces:

add_filter('get_usernumposts', 'wpforo_user_custom_post_type_count',10, 4);
function wpforo_user_custom_post_type_count( $count, $userid, $post_type, $public_only ){

$post_type = ['post']; //add comma separated custom post types['post', 'book', 'event',...]

if( function_exists('WPF') ){
global $wpdb;
if(is_wpforo_page()){
$where = get_posts_by_author_sql( $post_type, true, $userid, $public_only );
$custom_count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" );
if( $custom_count ) return $custom_count;
return $count;
}
}
}

In case you want to say thank you !)
We'd really appreciate and be thankful if you leave a good review on plugin page. This is the best way to say thank you to this project and support team.

Reply
jarruego liked
  All forum topics
  Previous Topic
Next Topic  
Related Topics
  • Simplfied Forum: Where is the user reg date & post count?
    3 months ago
  • Removing Categories in Member Activity Section?
    4 months ago
  • Not all users could be found in member list
    8 months ago
  • Help: How to add post count to simplified layout
    1 year ago
  • Disabling specific statistics displaying
    3 years ago
Topic Tags:  user statistic (2), profile statistic (4), post count (7), custom post type count (1), blog posts (1),

Forum Search

Join Us!

Download wpForo plugin
on WordPress.org

wpForo Addons

wpforo-private-messages wpforo-advanced-attachments-128x128 wpforo-embeds-128x128 wpForo User Custom Fields addon wpForo – Blog Cross Posting addon wpForo Ads Manager wpForo – WooCommerce Memberships Integration wpForo Emoticons wpForo – Tenor GIFs Integration
View all Addons »

Recent Topics

  • user can't access forum ( 404 ) after user role changed

    By perisaibanten165, 1 day ago

  • Suggestion Private Replies

    By shaleedt, 2 days ago

  • Why doesn't Google index pages?

    By Onurkansan, 2 days ago

  • Attachments not showing on forums posts after migration

    By Formicid, 4 days ago

  • New Feature About Plugin Customization and Integration

    By z14165899, 5 days ago

  • WordPress Email sending function wp_mail() doesn't work!

    By feassistant, 5 days ago

Topic Tags

  • css52
  • translation50
  • plugin conflict48
  • seo47
  • new features45
  • buddypress43
  • avatar41
  • moderation40
  • ultimate member40
  • login40
  • forum40
  • registration37
  • threaded layout35
  • cache34
  • spam33
  • editor33
  • menu33
  • shortcode32
  • forum accesses31
  • widget29
View all tags (2195)

Recent Posts

  • RE: İs there a way to use mobile push notifications on wpforo ? Like one signal push notifications?

    @alvina Can you at least give some information how to a...

    By przla, 19 mins ago

  • RE: Enable browser push notification

    @robert Are you thinking about adding it? Or at least m...

    By przla, 22 mins ago

  • RE: OneSignal push notification plugin integration

    @acornavi 3 years later. Did you have any luck with thi...

    By przla, 30 mins ago

  • Any chance to have a second way of notifying user about following posts via web push notifications?

    Hello, it has been asked many times many years ago (e.g...

    By przla, 31 mins ago

  • RE: user can't access forum ( 404 ) after user role changed

    Hi perisaibanten165, Please check this FAQ topic, it ...

    By Chris, 49 mins ago

  • RE: Why doesn't Google index pages?

    you are using dns caching You use Jetpack Photon (Per...

    By Tutrix, 2 days ago

  • Private Replies

    Is there a way to set the topic public but the comments...

    By shaleedt, 2 days ago

Share:
Share
Tweet
Share
  Forum Statistics
21 Forums
9,945 Topics
50.3 K Posts
11 Online
49 K Members

Latest Post: İs there a way to use mobile push notifications on wpforo ? Like one signal push notifications? Our newest member: billpenman9553 Recent Posts Unread Posts Tags

Forum Icons: Forum contains no unread posts Forum contains unread posts

Topic Icons: Not Replied Replied Active Hot Sticky Unapproved Solved Private Closed

Powered by wpForo | Copyright © 2016-2022 gVectors Team
Copyright Registration Service - Click here for more information or to register work
wpForo is Registered with the IP Rights Office
Copyright Registration Service

Ref: 4477265538
  • Home
  • Forum
  • Migrate to wpForo
  • Addons
  • Addons Demo
  • Documentation