Skip to:
Content

BuddyPress.org

Opened 18 months ago

Closed 18 months ago

Last modified 17 months ago

#8743 closed defect (bug) (worksforme)

xprofile_set_field_data it's not working on "Date selector"

Reported by: marioshtika's profile marioshtika Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Core Keywords:
Cc:

Description

Hello,

I am setting some field data programmatically using the xprofile_set_field_data function, as shown below.

xprofile_set_field_data(5, 21, '2017-12-03 07:53:00');

It is working fine when the field is set as a text box.
But If I change the field type to Date Selector, it is not saving it and it's returning false.

Is this a bug in there, or am I doing something wrong?

I didn't find any documentation that I have to use xprofile_set_field_data differently according to its type.

Thank you in advance

Change History (2)

#1 @imath
18 months ago

  • Milestone Awaiting Review deleted
  • Resolution set to worksforme
  • Status changed from new to closed

Hi,

That's because the pattern we use to validate a date is expecting the time to be 00:00:00, see line 31 of this file https://buddypress.trac.wordpress.org/browser/trunk/src/bp-xprofile/classes/class-bp-xprofile-field-type-datebox.php#L31

If you use xprofile_set_field_data(5, 21, '2017-12-03 00:00:00'); it should work as expected.

Thanks for posting this ticket, we're never too sure whether something weird is a bug or not 😅 As we don't handle time into this field type, I believe it's not a bug.

#2 @marioshtika
17 months ago

Hello @imath and thank you.

You were right, that was the case.

Note: See TracTickets for help on using tickets.