thalamus
12-18-2007, 12:43 AM
I hope the title's descriptive enough... ;)
Basically, I'm writing a plugin that hooks into the postbit_display_complete function, where I'm bringing in a user-defined profile field ("field5") that has, for its content, a multiple selection. I know that these are bit-set (i.e. & 1, & 2 etc for the options selected) and if I post it directly into the template as an '<if condition="$post[field5] & 1">' and so on for all the relevant bit fields, it works great.
Now I'm putting it into a plugin, to avoid core template changes on upgrades, and I'm trying to set the relevant variables within the plugin PHP code. The problem is, that I can't seem to get vBulletin to recognise that the $post[field5] value is a numeric...
The code I'm using is this (following this is a template str_replace):
$wnum = intval($this->post['field5']);
if ($wnum > 0) {
$add .= '<div>|$wnum|';
if ($wnum & 1) $add .= 'bit 1 set code';
if ($wnum & 2) $add .= 'bit 2 set code';
if ($wnum & 4) $add .= 'bit 4 set code';
if ($wnum & 8) $add .= 'bit 8 set code';
$add .= '</div>';
}
but $wnum always comes out as 0. I've also tried $wnum = vb_number_format($this->post['field5']) but same thing... doesn't really pick up the number.
Now, if I output the value to the template as in:
$wnum = intval($this->post['field5']);
$add .= '<div>Value: $wnum</div>';
it outputs the correct value.
Any thoughts or am I missing something really simple?
Basically, I'm writing a plugin that hooks into the postbit_display_complete function, where I'm bringing in a user-defined profile field ("field5") that has, for its content, a multiple selection. I know that these are bit-set (i.e. & 1, & 2 etc for the options selected) and if I post it directly into the template as an '<if condition="$post[field5] & 1">' and so on for all the relevant bit fields, it works great.
Now I'm putting it into a plugin, to avoid core template changes on upgrades, and I'm trying to set the relevant variables within the plugin PHP code. The problem is, that I can't seem to get vBulletin to recognise that the $post[field5] value is a numeric...
The code I'm using is this (following this is a template str_replace):
$wnum = intval($this->post['field5']);
if ($wnum > 0) {
$add .= '<div>|$wnum|';
if ($wnum & 1) $add .= 'bit 1 set code';
if ($wnum & 2) $add .= 'bit 2 set code';
if ($wnum & 4) $add .= 'bit 4 set code';
if ($wnum & 8) $add .= 'bit 8 set code';
$add .= '</div>';
}
but $wnum always comes out as 0. I've also tried $wnum = vb_number_format($this->post['field5']) but same thing... doesn't really pick up the number.
Now, if I output the value to the template as in:
$wnum = intval($this->post['field5']);
$add .= '<div>Value: $wnum</div>';
it outputs the correct value.
Any thoughts or am I missing something really simple?