Mark.B
11-12-2011, 12:33 PM
Right this one has me totally baffled and I can't fix it.
On vB3 I was able to query custom user fields (at the hook group_messagebit_display_complete) so the data could be used in the template group_message as follows:
$username = $message['username'];
$sql = "SELECT user.userid, user.usergroupid, userfield.field14, userfield.field13, userfield.field15
FROM user AS user
LEFT JOIN userfield AS userfield ON (userfield.userid = user.userid)
WHERE user.username = '" . mysql_real_escape_string($username) . "' LIMIT 1";
$query = mysql_query($sql);
// Do our error checking first...
if(!$query)
{
echo 'Username: Invalid';
}
else
{
// Use mysql_fetch_assoc to return [field] => [value] array result
$data = mysql_fetch_assoc($query);
$message['field14'] = $data['field14'];
$message['field13'] = $data['field13'];
$message['field15'] = $data['field15'];
}
Parts of this are borrowed from hacks on here.
Anyway this worked fine on vB3.
Now that I have reopened my groups on vB4 I thought I'd use the same code but it simply doesn't work.
Some diagnostics have revealed that the hook itself works, the problem seems to be that the variable $message is no longer recognised at this hook.
My test for that has been to add the following line:
$template_hook['field15'] = "Test";
I can then output {vb:raw template_hook.message15} in the template and it works.
But if I try:
$template_hook['field15'] = $message['username'];
Then {vb:raw template_hook.field15} returns nothing.
It can't be a variable registration issue as $message is definitely available in the template, it is already used throughout.
Therefore, I'm finally stumped. Anyone got any idea how I can plug this code in? Even if it means editing a file I don't mind.
On vB3 I was able to query custom user fields (at the hook group_messagebit_display_complete) so the data could be used in the template group_message as follows:
$username = $message['username'];
$sql = "SELECT user.userid, user.usergroupid, userfield.field14, userfield.field13, userfield.field15
FROM user AS user
LEFT JOIN userfield AS userfield ON (userfield.userid = user.userid)
WHERE user.username = '" . mysql_real_escape_string($username) . "' LIMIT 1";
$query = mysql_query($sql);
// Do our error checking first...
if(!$query)
{
echo 'Username: Invalid';
}
else
{
// Use mysql_fetch_assoc to return [field] => [value] array result
$data = mysql_fetch_assoc($query);
$message['field14'] = $data['field14'];
$message['field13'] = $data['field13'];
$message['field15'] = $data['field15'];
}
Parts of this are borrowed from hacks on here.
Anyway this worked fine on vB3.
Now that I have reopened my groups on vB4 I thought I'd use the same code but it simply doesn't work.
Some diagnostics have revealed that the hook itself works, the problem seems to be that the variable $message is no longer recognised at this hook.
My test for that has been to add the following line:
$template_hook['field15'] = "Test";
I can then output {vb:raw template_hook.message15} in the template and it works.
But if I try:
$template_hook['field15'] = $message['username'];
Then {vb:raw template_hook.field15} returns nothing.
It can't be a variable registration issue as $message is definitely available in the template, it is already used throughout.
Therefore, I'm finally stumped. Anyone got any idea how I can plug this code in? Even if it means editing a file I don't mind.