Can I change the way in which field values are displayed?
Yes, you can, since version 1.5.4, I have added a filter called «bxcft_show_field_value». You can use it and modify the value of your fields. For example, if you need to show only the day or month of the birthdate you need to add this code below in the functions.php of your theme:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
add_filter( 'bxcft_show_field_value', 'my_show_field', 15, 4); function my_show_field($value_to_return, $type, $id, $value) { $value_to_return = $value; if ($value_to_return == '') return $value_to_return; if ($type == 'birthdate') { $value = str_replace("<p>", "", $value); $value = str_replace("</p>", "", $value); $field = new BP_XProfile_Field($id); // Get children. $childs = $field->get_children(); $show_age = false; if (isset($childs) && $childs && count($childs) > 0) { // Get the name of custom post type. if ($childs[0]->name == 'show_age') $show_age = true; } if ($show_age) { return '<p>'.floor((time() - strtotime($value))/31556926).'</p>'; } return '<p>'.date_i18n( 'F j' , strtotime($value) ).'</p>'; } return $value_to_return; } |