Active
Project:
User Terms
Version:
6.x-1.4
Component:
Miscellaneous
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
19 Apr 2012 at 20:59 UTC
Updated:
20 Apr 2012 at 08:30 UTC
hi, I want to have block be visible only if they have any user term selected. I have used an existing code to do something similar that I found for retrieving user_terms via PHP but I have not ever used block permission PHP before. I have tried this but no go:
global $user;
$current = $user->uid;
if ($current > 0) {
$term = db_query("SELECT tid FROM {term_user} WHERE uid='$current'");
$result = db_fetch_object($term);
$result = $result->tid;
}
if ($result) {
return TRUE; // block will be shown
}
return FALSE;
}
ANyone have any ideas?
Comments
Comment #1
joachim commented> $term = db_query("SELECT tid FROM {term_user} WHERE uid='$current'");
Why are you passing a number in as a string? More to the point, escape your DB parameters!!!!
Second, there's no need for this anyway. user_load() should invoke user_terms_load_profile() which will load the terms. Or sidestep it and do user_terms_load_profile($user) yourself.
Finally, best do some debugging. You're in a better place to do it.