Notifications
Clear all

Limited Support

Our support team is currently on holiday from December 25, 2025 to January 7, 2026, and replies may be delayed during this period.

We appreciate your patience and understanding while our team is away. Thank you for being part of the wpForo community!

Merry Christmas and Happy Holidays! 🎄

New Feature [Solved] Unique Veiws and Reaccuring veiws

15 Posts
3 Users
1 Reactions
5,588 Views
Posts: 40
Topic starter
(@forumlover)
Trusted Member
Joined: 6 years ago

I see that the view count only counts a visitor one time even if they visit the page or post more times. This is not optimal for understanding page views for me. Is there a snippet of code that I can add or remove or both that will allow counting each time the page is loaded? 


Topic Tags
14 Replies
Robert
Posts: 10600
Admin
(@robert)
Support Team
Joined: 10 years ago

Hi @forumlover,

I'm sorry but there is no an easy way to enable it yet. We'll add this in our to-do and make this option.


Posts: 40
Topic starter
(@forumlover)
Trusted Member
Joined: 6 years ago

Well it's important I have it sooner than later or I need to go with a different forum that allowes views for returning page visits. Anyway to pay a small fee and get this change? Where in the code does it have the counting?


4 Replies
Robert
Admin
(@robert)
Joined: 10 years ago

Support Team
Posts: 10600

@forumlover

Ok, you can remove all filters and logics of unique counting of visitors.

For the 1.7.8 and above versions just put this hook code in your current active WordPress theme functions.php file:

add_filter('wpforo_filter_topic_views', '__return_false' );

 

For the 1.7.7 and lower versions do this change in the core file:

Use Plugin Editor or Website cPanle > File manager. Open this file: wp-content/plugins/wpforo/wpf-includes/functions.php

Find this function:

function wpforo_user_logging(){
$data = WPF()->current_object;
$visitor = WPF()->current_user;
if( wpfval($data, 'template') && $data['template'] == 'post' && wpfval($data, 'topicid') ){
//to-do: don't increase views before all read point.
if( WPF()->tools_legal['cookies'] ){
$viwed_ids = wpforo_getcookie( 'wpf_read_topics', false );
if( empty($viwed_ids) || !wpfval($viwed_ids, $data['topicid']) ){
WPF()->db->query("UPDATE `".WPF()->tables->topics."` SET `views` = `views` + 1 WHERE `topicid` = " . intval($data['topicid']));
}
}
elseif( is_user_logged_in() ){
if( wpfval(WPF()->current_usermeta, 'wpf_read_topics') ) {
$viwed_db_ids = wpforo_current_usermeta( 'wpf_read_topics' );
if( empty( $viwed_db_ids ) || !wpfval($viwed_db_ids, $data['topicid']) ){
WPF()->db->query("UPDATE `".WPF()->tables->topics."` SET `views` = `views` + 1 WHERE `topicid` = " . intval($data['topicid']));
}
} else{
WPF()->db->query("UPDATE `".WPF()->tables->topics."` SET `views` = `views` + 1 WHERE `topicid` = " . intval($data['topicid']));
}
}
}
}


Change it to this:

function wpforo_user_logging(){
$data = WPF()->current_object;
$visitor = WPF()->current_user;
if( wpfval($data, 'template') && $data['template'] == 'post' && wpfval($data, 'topicid') ){
WPF()->db->query("UPDATE `".WPF()->tables->topics."` SET `views` = `views` + 1 WHERE `topicid` = " . intval($data['topicid']));
}
}

(@forumlover)
Joined: 6 years ago

Trusted Member
Posts: 40

@robert

Let me test this.


Robert
Admin
(@robert)
Joined: 10 years ago

Support Team
Posts: 10600

@forumlover

Remember, the view count will not be changed live-time. Because it's under caching, it'll be reset after each new post or topic. If you want to test it you should click on [Delete all cache] button in Dashboard > Forums > Dashboard after each visit.

So the counting is going well but it'll not change the value on forum after each visit.


VereK
(@verek)
Joined: 8 years ago

Honorable Member
Posts: 522

@robert

It's actually d**n near live, a simple click back on the breadcrumbs will show the view count update.

Nice one. 👍 


Posts: 40
Topic starter
(@forumlover)
Trusted Member
Joined: 6 years ago

I have not tested but this reminds me of back in the day when people helped people without trying to charge them freaking as much as they can.


Posts: 40
Topic starter
(@forumlover)
Trusted Member
Joined: 6 years ago

Where is this located?

 

  • wpforo.php
  • wpf-assets folder
  • wpf-themes folder
  • wpf-includes folder
  • wpf-languages folder
  • wpf-admin

 


Page 1 / 3