Age not formatted right
-
I’m having an issue with the output in the age field. I have the field set at “show age” but it is showing this instead… 1993-12-18 00:00:00.
How can I resolve this. And thank you for updating the plugin! Really appreciate it.
http://wordpress.org/extend/plugins/buddypress-xprofile-custom-fields-type/
-
Mmmm, I’m testing in:
Wordpress 3.5
Buddypress 1.6.2
BP Xprofile Custom Fields Type 1.4.3The field set to show age works properly.
Can you check the versions?
I’m using W 3.5, BP XP 1.4.3 and BP 1.6.2 also, and I have already removed all of my plugins to see if something else was affecting it. Also, when I uncheck the show as age box it still shows the same way
We need to do some debug. Can you add this line of code in bp-xprofile-custom-fields-type.php line 381,382 you can see:
// Get children. $childs = $field->get_children();Below this line we must add this:
var_dump($childs);The code will look like this:
// Get children. $childs = $field->get_children(); var_dump($childs);Then reload the page where the age is supposed to be, copy and paste the code returned. It will look like this:
array
0 =>
object(stdClass)[4113]
public ‘id’ => string ’63’ (length=2)
public ‘group_id’ => string ‘1’ (length=1)
public ‘parent_id’ => string ‘3’ (length=1)
public ‘type’ => string ‘birthdate_option’ (length=16)
public ‘name’ => string ‘show_age’ (length=8)
public ‘description’ => string ” (length=0)
public ‘is_required’ => string ‘0’ (length=1)
public ‘is_default_option’ => string ‘1’ (length=1)
public ‘field_order’ => string ‘0’ (length=1)
public ‘option_order’ => string ‘1’ (length=1)
public ‘order_by’ => string ” (length=0)
public ‘can_delete’ => string ‘1’ (length=1)Thanks!
array(1) { [0]=> object(stdClass)#136 (12) { [“id”]=> string(3) “447” [“group_id”]=> string(1) “1” [“parent_id”]=> string(2) “85” [“type”]=> string(16) “birthdate_option” [“name”]=> string(8) “show_age” [“description”]=> string(0) “” [“is_required”]=> string(1) “0” [“is_default_option”]=> string(1) “1” [“field_order”]=> string(1) “0” [“option_order”]=> string(1) “1” [“order_by”]=> string(0) “” [“can_delete”]=> string(1) “1” } }
I must apologize… after I entered the code and looked around the site for the output, I noticed that the field that is SUPPOSED to show the age shows correctly!
I have the age in the members-header and a few other places around the site (sidebar, etc.) and it is showing the 1993-12-18 00:00:00 format in those areas.
I’ve placed: <?php if ( $data = bp_get_profile_field_data( ‘field=Age’ ) ) : ?><?php echo $data ?> To call the age.
Is is possible to get the correct display for age in the header?
I really appreciate you taking the time to reply back to me, and I’m sorry for the inconvenience.
No problem, thanks for reporting issues.
We have just released version 1.4.4. I think it will solve your issue.
WOW! It did! Thank you so much!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
😉
You welcome!Sorry to bother you again… but is there a way to get the age to stay on the same line? It moves to the line below in the Buddypress Avatar Bubble plugin…
It looks like this:
Age:
19All the other lines show like this:
Gender: Female
Country: USAThank you again!
Never mind 🙂 Figured out a shortcut, just removed the <p></p> from the file and it works great now.
Ok. I was going to say you to remove this…xD.
Hi Donmik,
As my question is somewhat relevant to this thread I’ll post it here.
I would like to remove the <p>…</p> that gets added to the birthdate field (and preferably all fields). I know there is this code below:
add_filter( 'bxcft_show_field_value', 'my_show_field', 15, 4); function my_show_field($value_to_return, $type, $id, $value) { 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; }But I’m not sure how to edit that just to remove the <p></p> and keep the rest the same.
Thanks,
Alex
Hi,
Sorry for the delay. If you delete the “<p>” tag in this code, I think it will work. The rest of fields should stay the same.
guess that was somewhat obvious. Thanks donmik.
hey there,
i use wp 3.6 and BP 1.8.1. i have the problem that the birthdate field does not show up. i can see the field description, but not the field to choose day/month and year. that prevents the whole registration process from working. do you have a hint for me?
The topic ‘Age not formatted right’ is closed to new replies.