• Hello Fabrik Community

    Fabrik is now in the hands of the development team that brought you Fabrik for Joomla 4. We have recently transitioned the Fabrik site over to a new server and are busy trying to clean it up. We have upgraded the site to Joomla 4 and are running the latest version of Fabrik 4. We have also upgraded the Xenforo forum software to the latest version. Many of the widgets you might have been used to on the forum are no longer operational, many abandoned by the developers. We hope to bring back some of the important ones as we have time.

    Exciting times to be sure.

    The Fabrik 4.0 Official release is now available. In addition, the Fabrik codebase is now available in a public repository. See the notices about these in the announcements section

    We wish to shout out a very big Thank You to all of you who have made donations. They have really helped. But we can always use more...wink..wink..

    Also a big Thank You to those of you who have been assisting others in the forum. This takes a very big burden off of us as we work on bugs, the website and the future of Fabrik.

Scheduled mail based on users' last visit date

miss.take

New Member
Hi all.
I searched in the community forum, but all the code found seems to be like mine...
I want to send an email to the user just 30 days before their profiles expire.
My workflow consider expiration time based on last visit date. So my users simply must log-in before lastVisitTime + 365 days to mantain their profiles activated.
I want to send an email 30 days before the expiration.
So
1. New scheduled;
2. Connection on previously imported user table;
3. Email plugin.
Mi php condition (for the moment in just +1 day to comfortly test the code):

PHP:
$ultimavisita = $row->dz8v4_users___lastvisitDate;
$checkdate = date('Y-m-d');
$ultimavisita = strtotime($ultimavisita);
$checkdate = strtotime($checkdate);
$ultimavisita = date('Y-m-d', $ultimavisita);
$checkdate = date('Y-m-d', $checkdate);
$ultimavisita = date('Y-m-d', strtotime($ultimavisita . " + 1 days"));
//in production must be +335 days
return $ultimavisita == $checkdate;

Tried using cron execution tool... and the results returned are always false.
I expect it to be true for at least three of my users (logged yesterday as checked on the DB).
I'm sure my code is good...
I'm just not sure about the dates collected at the beginning
$ultimavisita = $row->dz8v4_users___lastvisitDate

How can I print my viariables in condition field?
Any idea about what is wrong in my code?

Thanks in advance.
Valerio
 
Ok.
Using fabrik debug
index.php?fabrik_cron=2&fabrikdebug=1
and echoing my vars in the php condition I'm now sure that the problem is
Code:
$row->dz8v4_users___lastvisitDate;
that seems to be null...
$ultimavisita: 1970-01-02
$checkdate: 2020-03-27
Why?
 
Thanks a lot Troester... and sorry for my late, but I didn't think to have a rapid response due to the exceptional moment we're living...
I'm back in Joomla after years... so sorry if I was confused about the $row nature.
The simplest solution is definitely to use the placeholders.
This is a test code: so to let it works I had to use a different time interval of 1day.
Just change the time in last $ultimavisita to obtain the alert at the needed day:

PHP:
$ultimavisita = '{dz8v4_users___lastvisitDate_raw}';
$checkdate = date('Y-m-d');
$ultimavisita = strtotime($ultimavisita);
$checkdate = strtotime($checkdate);
$ultimavisita = date('Y-m-d', $ultimavisita);
$checkdate = date('Y-m-d', $checkdate);
$ultimavisita = date('Y-m-d', strtotime($ultimavisita . " + 1 days"));
return $ultimavisita == $checkdate;
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top