AI Search
Classic Search
 Search Phrase:
 Search Type:
Advanced search options
 Search in Forums:
 Search in date period:

 Sort Search Results by:

Filter by custom fields

Topic prefix

AI Assistant
Notifications
Clear all

[Solved] Unique Veiws and Reaccuring veiws

15 Posts
3 Users
1 Reactions
10.6 K Views
Posts: 42
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@forumlover)
Trusted Member
Joined: 7 years ago
[#9342]

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: 10716
Admin
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@robert)
Support Team
Joined: 2 months 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: 42
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@forumlover)
Trusted Member
Joined: 7 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: 2 months ago

Support Team
Posts: 10716
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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: 7 years ago

Trusted Member
Posts: 42
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@robert

Let me test this.


Robert
Admin
(@robert)
Joined: 2 months ago

Support Team
Posts: 10716
Robert
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@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
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian

@robert

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

Nice one. 👍 


Posts: 42
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@forumlover)
Trusted Member
Joined: 7 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: 42
Topic starter
Translate
English
Spanish
French
German
Italian
Portuguese
Russian
Chinese
Japanese
Korean
Arabic
Hindi
Dutch
Polish
Turkish
Vietnamese
Thai
Swedish
Danish
Finnish
Norwegian
Czech
Hungarian
Romanian
Greek
Hebrew
Indonesian
Malay
Ukrainian
Bulgarian
Croatian
Slovak
Slovenian
Serbian
Lithuanian
Latvian
Estonian
(@forumlover)
Trusted Member
Joined: 7 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
Share: