1. desoxire
  2. General
  3. Tuesday, May 15 2018, 05:24 PM
Hello!

I would like to have a hidden date-field which always has the current date/time as value.
This would help us know, when a profile was updated the last time.

Is this possible? Can you please give me a hint, how to do so?

Thank you very much!
admin Accepted Answer
Admin
Hi,
Easy Profile does not do this natively but you can create a plugin that update a date field, follow these steps:
- Create a Date field type (not shown in edit profile and registration pages)
- Download, Install and Enable Skeleton Plugin (you will find it at http://docs.easy-profile.com/index.php/article/triggers)
- Open file /plugins/jsn/skeleton/skeleton.php
- remove samples functions: triggerFieldAvatarUpdate, triggerProfileUpdate
- add function like this:
public function triggerProfileUpdate($user, &$data, $changed, $isNew)
{
if(!$isNew)
{
$data['alias_of_the_field'] = date("Y-m-d H:i:s");
}
}
Replace alias_of_the_field with alias of your field.

NOTE: This code is not tested and not supported, this is only for example purpose.
  1. more than a month ago
  2. General
  3. # 1
desoxire Accepted Answer
Pro
Hello! Thank you very much. Unfortunatedly this has no effect on my date fields. in the database is the value 0000-00-00 00:00:00

In my date fields i selected following date formats: See attachment

The skeleton plugin is installed and active.

Here is my code. I have two date fields. One should contain the date of user registration. The other should alwasys contain the date of the last edit.


<?php
defined('_JEXEC') or die;

class PlgJsnSkeleton extends JPlugin
{
public function triggerProfileUpdate($user, &$data, $changed, $isNew)
{
if(!$isNew)
{
$data['datum_profil_bearbeitet'] = date("d.m.Y H:i:s");
}

if($isNew)
{
$data['datum_profil_angelegt'] = date("d.m.Y H:i:s");
}
}
}
?>


Can you please help me to get this work? Thank you!!!
  1. more than a month ago
  2. General
  3. # 2
admin Accepted Answer
Admin
Hi,
you need to store in database the raw format, so the format of the date field need to be compliant with SQL date format.

In date function you need to use "Y-m-d" instead "d.m.Y"
  1. more than a month ago
  2. General
  3. # 3
  • Page :
  • 1


There are no replies made for this post yet.
However, you are not allowed to reply to this post.