UPDATES EasyBlog 6.0.11 Released! Update to the latest version now!

Helpdesk

Your Time
Our Time
Response Time
24 — 48 hours
We strive to provide the fastest ever response possible. However, we are not super beings.

Allow at least 24 — 48 hours
  Support is offline
Our team is away during the weekend. Some answers may already be available on our documentation

Rest assured that we will get back to your posts as soon as the week starts!
  Support is offline

Update User Birthday value

Daniel Pierce · ·
8:49 AM Wednesday, 16 August 2017
Normal
Support,

I have a small app that I want to display the user BIRTHDAY field and update it if it has not been filled in.

I'm able to use the getFieldValue('BIRTHDAY') to get the value that is set in the BIRTHDAY field. Works just fine. Here is the test code to pull the field value using the SocialFieldsUserDateTimeObject.


require_once ( JPATH_BASE . 'administrator' . DS . 'components' . DS . 'com_easysocial' . DS . 'includes' . DS . 'easysocial.php' );
require_once ( JPATH_BASE . 'administrator' . DS . 'components' . DS . 'com_easysocial' . DS . 'includes' . DS . 'user' . DS . 'user.php' );
require_once ( JPATH_BASE . 'media' . DS . 'com_easysocial' . DS . 'apps' . DS . 'fields' . DS . 'user' . DS . 'datetime' . DS . 'datetime.php' );

$user_id = (int) '658';
$user = ES::user($user_id);
echo ( '<br>');
echo ('Retreived Birthday' );
$user_birthday = $user->getFieldValue( 'BIRTHDAY' );
var_dump($user_birthday);
echo ( '<br><br>');

//$birthday = new DateTime( $user_birthday );
$new_birthday = new SocialFieldsUserDateTimeObject();
$new_birthday = $user_birthday->value;

echo ( '<br><br>');
echo( 'Year: ' . $user_birthday->value->year );
echo ( '<br>');
echo( 'Month: ' . $user_birthday->value->month );
echo ( '<br>');
echo( 'Day: ' . $user_birthday->value->day );
echo ( '<br>');
echo( 'hour: ' . $user_birthday->value->hour );
echo ( '<br>');
echo( 'minute: ' . $user_birthday->value->minute );
echo ( '<br>');
echo( 'second: ' . $user_birthday->value->second );



So I can get the users Birthday value which is GREAT. The problem I'm having is getting EasySocial to set the Birthday field value with the saveFieldValue. Here is the code I'm using which does nothing. What am I missing?


require_once ( JPATH_BASE . 'administrator' . DS . 'components' . DS . 'com_easysocial' . DS . 'includes' . DS . 'easysocial.php' );
require_once ( JPATH_BASE . 'administrator' . DS . 'components' . DS . 'com_easysocial' . DS . 'includes' . DS . 'user' . DS . 'user.php' );
require_once ( JPATH_BASE . 'media' . DS . 'com_easysocial' . DS . 'apps' . DS . 'fields' . DS . 'user' . DS . 'datetime' . DS . 'datetime.php' );

$user_id = (int) '658';
$dttm = new SocialFieldsUserDateTimeObject();

// Set the necessary data you want on this object.
$dttm->year = (string) '1965';
$dttm->month = (string) '02';
$dttm->day = (string) '01';
$dttm->hour = (string) '00';
$dttm->minute = (string) '00';
$dttm->second = (string) '00';

$user = ES::user($user_id);
$user->setFieldValue('BIRTHDAY', $dttm->toDate() );



Looking at the methods in the /media/com_easysocial/apps/fields/user/datetime.php the toDate() method should get the date from the object. I've tried just passing the DateTimeObject and also setting the $dttm->date value but that is a private field.

Love to get your direction why this is not working as it looks like it should.
Thanks for the help.

ALSO, where did the Developer documentation go? Can't find it on the web site.
The replies under this section are restricted to logged in users or users with an active subscription with us