Plugin Author
donmik
(@atallos)
Hi,
The filter seems all right. Check if the if you are using is working. Something like this:
add_filter( 'bxcft_show_field_value', 'my_show_field', 15, 4);
function my_show_field($value_to_return, $type, $id, $value) {
if ($type == 'number') {
$value = str_replace("<p>", "", $value);
$value = str_replace("</p>", "", $value);
$field = new BP_XProfile_Field($id);
if ($field->name == 'Waarde van je gadget (€)') {
echo "WE ARE HERE!!!";
setlocale(LC_MONETARY, 'nl_NL');
$value = money_format('%.2n', $value) . "\n";
$new_value = money_format('%.2n', $value) . "\n";
} else {
$new_value = $value;
}
return '<p>'.$new_value.'</p>';
}
return $value_to_return;
}
If you are not seeing the string “WE ARE HERE!!!”, the error is in the if sentence. So check what is inside $field->name and compare with your string.
he man, thanks for your answer and sorry for the late response. I just checked your code and it gives me the WE ARE HERE string in the “waarde van je gadget” box. so the error is not in the if statement. However all the fields that should come right under the waarde van je gadget box are hidden/disappeared…and i’m still not able to show the values as valuta, maybe because the value stored in the wp_bp_xprofile_data table in the database are stored as long text? I really hope you can help me with this one 🙂 Cheers
i think the error is in the
`$value = money_format(‘%.2n’, $value) . “\n”;
$new_value = money_format(‘%.2n’, $value) . “\n”;`
shouldn’t $value be referring to a value in the database?
Plugin Author
donmik
(@atallos)
Try to activate WP_DEBUG to see if there is any error.
Also do a var_dump($value); to see what $value is.
allright thanks man! i got it working with the following code:
// currency
add_filter( 'bxcft_show_field_value', 'my_show_field', 15, 4);
function my_show_field($value_to_return, $type, $id, $value) {
if ($value_to_return == '')
return $value_to_return;
if ($type == 'number') {
$value = str_replace("<p>", "", $value);
$value = str_replace("</p>", "", $value);
$field = new BP_XProfile_Field($id);
if ($field->id == '18' ) {
$f_value=number_format($value,2);
$new_value = "€ $f_value,-";
} else {
$new_value = $value;
}
return '<p>'.$new_value.'</p>';
}
return $value_to_return;
}
*field id 18 = field name gewenste dekking(E).
I have on more question how can i make this work for multiple fields, say like 2, 18 and 19 without putting the whole code back again? strangly ‘2,18,19’ isn’t working…
thanks again!
Plugin Author
donmik
(@atallos)
Hi, you need to do something like this:
$ids = array(2, 18, 19);
if (in_array($field->id, $ids)) {
You can add all the ids to the array.
instead of
if ($field->id == '18') {
Thanks man! works like a charm 😀