Skip Navigation

[Resolved] How can display the _cred_notification_data current timestamp in a view

This thread is resolved. Here is a description of the problem and solution.

Problem:
How can display the _cred_notification_data current timestamp in a view

Solution:
You can use the [cred-post-expiration id="[wpv-post-id]" format="m/d/Y"] shortcode to display the post expiration date.

You can find the proposed solution in this case with the following reply:
https://toolset.com/forums/topic/how-can-display-the-_cred_notification_data-current-timestamp-in-a-view/#post-1512921

Relevant Documentation:
=> https://toolset.com/documentation/user-guides/front-end-forms/automatic-post-expiration/#displaying-information-about-the-expiration-date-on-the-front-end

This support ticket is created 4 years, 10 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 8 replies, has 2 voices.

Last updated by mikeB-14 4 years, 10 months ago.

Assisted by: Minesh.

Author
Posts
#1512659

Hi
In the meta data of post you have a field array which record the timestamp when the filed is changed and a notification is sent.

_cred_notification_data

'a:1:{i:35913;a:2:{s:9:"cred_form";i:35913;s:7:"current";a:3:{s:4:"time";i:1566206895;s:11:"post_status";s:7:"publish";s:8:"snapshot";s:0:"";}}}'

I would like to display date that this happened in a view. I think the part i am lookng for is the time element of the array.
What we are finding is that some of our users are create the post which we i can get the date create and mod of the post. , but the then triggering the field with the notification flag many be done days later.
So my example is a user may create delegates who me be attending an event 6 weeks in advance , but will sent the email notification a lot later.
Thanks
Tony

#1512861

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Do you mean that you want to display the post expiration date value?

#1512889

So we have a check box called 'email request' and it's status is unchecked on creation of the post.
When the user tick the checkbox we test see if the status has changed to 1 and we trigger the email notification.
What i have seen based in exporing the data using WP AIl Export is this field _cred_notification_data

'a:1:{i:35913;a:2:{s:9:"cred_form";i:35913;s:7:"current";a:3:{s:4:"time";i:1566206895;s:11:"post_status";s:7:"publish";s:8:"snapshot";s:0:"";}}}'

I have already created a function in WP All Export which does extract the element i want
:"current";a:3:{s:4:"time";i:1566206895;
And as we are only filtering for the checkbox ticked, that gives me the snapshot of the ticked event.

So if you untick and save the post , that save a update in that field and if you tick it again it updates it again.
Each time with the timestamp.
So can i get that to show in a view as a date field ?

Tony

[php]
<?php
$data = 'a:1:{i:35913;a:2:{s:9:"cred_form";i:35913;s:7:"current";a:3:{s:4:"time";i:1566206895;s:11:"post_status";s:7:"publish";s:8:"snapshot";s:0:"";}}}';

$dataUnserialized = unserialize($data);

recursive3($dataUnserialized);

function recursive3($value)
{
$dataUnserialized = unserialize($value);
foreach ($dataUnserialized as $key => $value)
{
if (is_array($value))
{

$date_res = array_column($dataUnserialized, 'current');

$string = implode("|", $date_res[0]);

if (strpos($string, "|") !== false)

$string = explode("|", $string);

$datetotest = intval($string[0]);

return date('Y-m-d', $datetotest);

}
else
{

return date('Y-m-d', $datetotest);

}
}
}

?>

#1512897

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Do you mean that within your view that query the specific post type wherewith that post type post-expiration settings available and Now, you want to display the date that is returned by recursive3 function you created?

#1512909

Yes if possible

So it would mean that the function will feed in the
$data = _cred_notification_data
$dataUnserialized = unserialize($data);
etc..
for that post and return the that value
Hope it make sense.
Thanks
Tony

#1512921

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Can you please check the following Doc and it gives you the same date as per your requirement;
=> https://toolset.com/documentation/user-guides/front-end-forms/automatic-post-expiration/#displaying-information-about-the-expiration-date-on-the-front-end

For example - within yu view, you need to add the shortcode as given under:

[cred-post-expiration id="[wpv-post-id]" format="m/d/Y"]
#1512979

Hi Minesh
That field appears blank on my view.
I don't use expiration dates on my custom posts
OK I have just look at the data again
Can i get the Created Date and Modified Date of the post then in the view, using shortcodes then ?

Thanks
Tony

#1512987

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You can display the psot date using the following shortcode: [wpv-post-date]

And modified date using the following shortcode: [wpv-post-date type="modified"]

More info:
=> https://toolset.com/documentation/user-guides/views/views-shortcodes/#wpv-post-date

#1512999

My issue is resolved now. Thank you!