User visits is not recorded or shown as 0 if this block is enabled in
advanced profile.

user_visits.module can record the number of visits an user-profile has.
But when advanced profile is used ( with bio and usernode ) the count is shown as
zero.

Can some minor changes be done so that this is seen ?

Comments

michelle’s picture

Project: Advanced Profile Kit » User Visits
Version: 5.x-1.0-alpha5 » 5.x-1.x-dev
Category: bug » feature

User visits would need to be adapted to work when the user profile page is overridden by panels. Moving this to that queue.

Michelle

sanduhrs’s picture

Title: User visits is not recorded or shown as 0 » User visits is not recorded with Advanced Profile Kit
Status: Active » Postponed (maintainer needs more info)

So, how would you determine that a panel overrides a user profile?

dropchew’s picture

Right, I have the same problem. Hope this can be enhanced to work with APK. Subscribe

michelle’s picture

Title: User visits is not recorded with Advanced Profile Kit » User visits are not recorded when user profile page overridden by panels

Changing the title to be more accurate. This isn't an issue with APK; it's an issue with the panels override. I'll point sdboyer here and maybe he'll have an idea.

Michelle

ibexy’s picture

got same problem subscribing...

mariusooms’s picture

Actually...it is even broader than that. Visits are only recorded on profile visits, whenever you use content as profile solutions, the module does not count the visits. For example also by using the content profile module in Drupal 6.

Any clue as how to make the module support a wider range of visit situations would be very appreciated.

Regards,

Marius

minesota’s picture

Can 'statistics' be enabled then for this ? I have not used that module though.
If this is 'content' stats can count the views, which should be equivalent to views ?

If it can be, next thing will be how or where to show the count on the profile page?
This will however not enlist the latest visitors and/or their icons in a block.

rsvelko’s picture

I am using Advanced Profile Kit (which uses Panels2 (which takes over the profile page and it is no longer a node nor caught by hook_user ... ) )

I figured out that if I make a block like this it would count visits and log them to the user_visits table:


<?php
global $user;

if($user->uid) {
$profile_viewer = check_plain($user->name);
}

$vuid = $user->uid; // visitor uid for user visits

$uid = arg(1); // profile_owner  (works  also for user_visits )
$account = user_load(array('uid' => $uid));
$profile_owner = $account->name;

// display  usercontrols to owner
if ($profile_owner == $profile_viewer)
{
print '
----- User controls links go here (edit profile etc) -----
---- look for the user visits part below ----

';

}


// count user visits  (taken from user_visits module)

//function user_visits_count($vuid, $uid) {

if ( $uid != $vuid ) {
  db_query("DELETE FROM {user_visits} WHERE uid=%d AND vuid=%d", $uid, $vuid);
  db_query("INSERT INTO {user_visits} (uid, vuid, visit, referer) VALUES (%d, %d, %d, '%s')", $uid, $vuid, time(), referer_uri());
}
//}

// get and display total visits
$total_visits = db_result(db_query("SELECT COUNT(visit) AS count FROM {user_visits} WHERE uid=%d", $uid));

// display recent n
$limit = 5;

//function user_visits_latest($uid, $limit = 5) {
  $result = db_query("SELECT * FROM {user_visits} WHERE uid=%d ORDER BY visit DESC LIMIT %d", $uid, $limit);
  
  while ($visitor = db_fetch_object($result)) {
    $visitors[] = $visitor;
  }
//  return $visitors;
//}

//    $visitors = user_visits_latest($uid, $limit);
    if (is_array($visitors)) {
      foreach ($visitors as $visitor) {
        $account = user_load(array('uid' => $visitor->vuid));
        $output .= theme('user_visits', $account, $visitor->visit); //  $visitor->visit is the time
      }
    }
    $output .= theme('user_visits_total', $total_visits /*user_visits_total($uid)*/ ); // changed from user_visits module


print "------<br>" . $output . "<br>----------<br>";

?>


So once again - I am using this in a block in my site - which block I embed in a panel ... It uses the table of user_visits module.

Later I will submit a patch - either embeding this code in a hook or just in a block provided from user_visits - speciffically for those who use Panels2.....

PS For now you will have to change the theme() part at the end to customize the look of the recent visits list ... Just look at what it emits as html and then copy it to the block removing the theme() call. Will be made more flexible later.

michelle’s picture

Just thought I'd mention for people using APK that the lastest version will display recent visitors to the profile using the logs right out of Drupal core rather than this module. Doesn't do people not using APK any good so that's not a fix for this, but there's a couple APK users on this thread.

Michelle

dawehner’s picture

why not execute user_visits_latest() on hook_exit and check for the current path

pro:
- less code
- its executed for panels too

cons:
- impossible to use it on alternatives paths

sanduhrs’s picture

Assigned: Unassigned » sanduhrs
Status: Postponed (maintainer needs more info) » Needs review
StatusFileSize
new5.17 KB

Attached is a patch, that adds an advanced section to the settings page, where one may define a custom path to record.
hook_exit is probably the best to put it.

Please have a look and report back, if its working for you.
Thanks.

dawehner’s picture

StatusFileSize
new5.1 KB

here is the same patch for the drupal6 version

sanduhrs’s picture

Version: 5.x-1.x-dev » 7.x-1.x-dev
Issue summary: View changes

Moving version up.

sanduhrs’s picture

Status: Needs review » Closed (outdated)