Hi,

I wanted to count the number of flags of a special kind the currently logged in user has placed on nodes:

<?php
global $user;
$flag = flag_get_flag('name_of_the_flag');
$count = $flag->get_user_count($user->uid);

print $count;
?> 

I wanted to use this code in a view as well as in the template for the the content type - in both cases "0" is shown although the logged in user used this flag for some nodes. Did I something wrong?

Greez,
Tobias

Comments

tobiberlin’s picture

Any ideas?

quicksketch’s picture

That exact code works for me just fine.

tobiberlin’s picture

Status: Active » Fixed

Ok, I just found out that the used flag was global so that in database table no user id is saved. By changing the flag to a non-global one this code allows to count the number of flags of a special kind a user has set.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.