-
Author
-
May 17, 2015 at 17:25 #59201
maelga
ParticipantHi, I have a few profile fields that currently display dates like this: 2016-01-02 00:00:00
How can I format all these dates to show in this format: DD MMM YYYY (e.g. 17 May 2015)?
Thanks
May 19, 2015 at 02:24 #59335Laura
ModeratorHello, have you tried the plugin https://wordpress.org/plugins/buddypress-xprofile-custom-fields-type/ ?
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionMay 6, 2016 at 10:07 #120659LuukDriessen
ParticipantHello Laura,
We also make use of this plugin. But I can’t get it to work.
We are confused with the sweetdate options.
I use the correct code in the functions.php
When viewing memberspage, I get the date and time instead of the age.
Als when viewing the profile i get: Dat of Birth intead of ‘Age’. The age self is showing correctly.
Which sweetdate options do I need to use?
May 6, 2016 at 13:07 #120668LuukDriessen
ParticipantHello Laura,
We did a clean install with Sweetdate.
We still have problems with the age/date of birth.
1. We can’t get to show ‘Age’ instead of ‘Date of Birth’ on our profile
http://www.ikbenopzoeknaarklanten.nu/leden/luigid/profile/
User: LuigiD
ww: lvd817mld!2. When in the Member overview we can only see the date of birth. We also uses the custom code from.
COPY CODE<?php add_filter( 'bp_get_the_profile_field_value', 'kleo_get_field_value', 1433); function kleo_get_field_value($value, $type, $field_id) { $value_to_return = $value; $field = new BP_XProfile_Field($field_id); if ($type == 'datebox') { $value_to_return = floor((time() - strtotime($field->data->value))/31556926); } return $value_to_return; } ?>ID 1433 is the dat of birth field. But in the examples are 2 ID’s. Maybe this is my problem?
I would be very helpful when this is solved
Thanks in advance
Gr Luuk
May 9, 2016 at 20:16 #121061Laura
ModeratorHello, if you go to Sweetdate > Buddypress, you will find the age field selector and you will also see the use age instead of birthday checkbox
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionMay 9, 2016 at 22:29 #121078LuukDriessen
ParticipantHello Laura,
Yes, ofcourse.
We use Xprofile to show the date of birth field.
We succesfully showed the age on the members profile.
Question 1: What do I have to do to show ‘Age’ instead of ‘DateofBirth’
Question 2: Which code do I need to use to show the ‘Age’ on the members overview page?
When activating in theme the Xprofile plugin shows the DateofBirthThanks in advance.
We had all these functions working correctly without Xprofile plugin.
So now we need to use another code?May 11, 2016 at 02:05 #121278Laura
ModeratorHello, at Sweetdate > Buddypress and you will see birthday and the check show age instead of birthday
Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionMay 11, 2016 at 02:29 #121285LuukDriessen
ParticipantHello Laura,
Thanks for your response.
Unfortunately we don’t understand eachother.
I know when selecting sweetdate > buddypress I can check for age etc.
But since we make use of Xprofile to enter the users dateofbirth, the age isn’t showing anymore.
Thats why I asked these questions.
Maybe you can/want to take a look.
http://www.canna-dating.nl/inloggen
Login: LuigiD
pw: lvd817mld!
When forwarded > http://www.canna-dating.nl/wp-admin/After login:
http://www.canna-dating.nl/leden/
http://www.canna-dating.nl/leden/luigi-d/profile/All DoB are shown instead of age.
Many thanks for your support
May 11, 2016 at 14:49 #121332Laura
ModeratorHello, will assign the ticket to a higher support level who can help and advise you in your query.
Thanks! 🙂Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionMay 11, 2016 at 17:52 #121371Radu
ModeratorHi,
Try to use date() instead the time() it seems that the time add extra details like hours:minutes:seconds
Similar topic here : https://archived.seventhqueen.com/forums/topic/xprofile-fields-plugin-compatability-with-sweet-date
http://stackoverflow.com/questions/2829120/mktime-php-date-timestamp-yyyy-mm-dd
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionMay 12, 2016 at 00:31 #121443LuukDriessen
ParticipantHello Radu,
Thank you for your reply. Really appreciate the support.
I tried to use the changes. The same problem occurs.
add_filter( ‘bp_get_the_profile_field_value’, ‘kleo_get_field_value’, 1, 2);
Question: Which ID’s I need to select? Ofcourse the field_id of the dateofbirth. But what about the other ID?The settings in the theme don’t make sense since using Xprofile.
May 12, 2016 at 18:22 #121533Radu
ModeratorHi again,
Try with this
COPY CODEadd_filter( 'bp_get_the_profile_field_value', 'kleo_get_field_value', 999, 3); function kleo_get_field_value($value, $type, $field_id) { if ($type == 'datebox') { $field = new BP_XProfile_Field($field_id); $birthdate = new DateTime($field); $today = new DateTime('today'); $age = $birthdate->diff($today)->y; return $age; } return $value; }Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionMay 12, 2016 at 19:03 #121542LuukDriessen
ParticipantThanks again for your reply Radu, really awesome.
I implemented the code in functions.php
Also no difference.Strange thing:
Show age instead of birthdate
Enable to show members age insted of Birtdate in user profile.When changing this to OFF the age is showing.
When changing to ON, the date and time are showing.Unfortunately I also can’t get the AGE label showing.
I have 3 installs. 1 clean install. On all 3 the same problems.
When not using Xprofile the theme is working correct.
Maybe there is a way I can pay you to solve this problem?
May 12, 2016 at 19:28 #121553Radu
ModeratorHi,
I don’t have available to much time but leave there ftp and admin credentials to the clean install where you have to setup the fields for age etc.
After i solve your problem give me how much do you want for this job.Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.