This topic has 13 replies, 4 voices, and was last updated 8 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

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #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
    This reply has been set as private.
    #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

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #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

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #121285
     LuukDriessen
    Participant
    This reply has been set as private.
    #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

    Laura Solanes - Graphic Designer and Web Designer

    Please be patient as I try to answer each topic as fast as i can.

    If you like the theme or the support you've received please consider leaving us a review on Themeforest!

    Always happy to help you 🙂

    #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
    This reply has been set as private.
    #121553
     Radu
    Moderator
    This reply has been set as private.
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?