We could get the flagged items by making the flag_get_user_flags() call. Assume we have setup a user flag called connect, the following example will return a list of a “connected” users which are flagged by a specific user (uid = 29).
print_r(flag_get_user_flags('user', null, 29, null, false));
// Returned array
Array (
[connect] => Array (
[1] => stdClass Object (
[fcid] => 95
[fid] => 4
[content_type] => user
[content_id] => 1
[uid] => 29
[sid] => 0
[timestamp] => 1323157400
)
[19] => stdClass Object (
[fcid] => 92
[fid] => 4
[content_type] => user
[content_id] => 19
[uid] => 29
[sid] => 0
[timestamp] => 1323157397
)
)
)
Please note that the returned array has the following structure. The content id would be either user id or node id, depending on the first parameter of the function (i.e. ‘user’ or ‘node’).
[flag_name] => [content_id]
So for user with uid = 29, he has 2 connected users whose ids are 1 and 19 respectively.
Done =)
Reference: Lullabot – flag_get_user_flags
