This topic has 13 replies, 4 voices, and was last updated 9 years by Radu.

  • Author
  • #59201
     maelga
    Participant

    Hi, 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

    #59335
     Laura
    Moderator

    Hello, 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 solution
    #120659
     LuukDriessen
    Participant

    Hello 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?

    #120668
     LuukDriessen
    Participant

    Hello 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

    #121061
     Laura
    Moderator

    Hello, 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 solution
    #121078
     LuukDriessen
    Participant

    Hello 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 DateofBirth

    Thanks in advance.

    We had all these functions working correctly without Xprofile plugin.
    So now we need to use another code?

    #121278
     Laura
    Moderator

    Hello, 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 solution
    #121285
     LuukDriessen
    Participant

    Hello 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

    #121332
     Laura
    Moderator

    Hello, 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 solution
    #121371
     Radu
    Moderator

    Hi,

    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 solution
    #121443
     LuukDriessen
    Participant

    Hello 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.

    #121533
     Radu
    Moderator

    Hi again,

    Try with this

    COPY CODE
    
    add_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 solution
    #121542
     LuukDriessen
    Participant

    Thanks 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?

    #121553
     Radu
    Moderator

    Hi,

    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
Viewing 14 posts - 1 through 14 (of 14 total)

The forum ‘Sweetdate – WordPress’ is closed to new topics and replies.

Log in with your credentials

Forgot your details?