Skip Navigation

[Resolved] 1 day before expiration date of post

This support ticket is created 7 years, 4 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

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 Bochnacki 7 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#546686

Based on https://toolset.com/forums/topic/wp-if-compare-with-a-date/ I made a shortcode and I want to use it in the View. However, I can not write wpv-conditional for "cred-post-expiration".
My shortcode:

function get_today_date() {
    return strtotime("1 day");
}
add_shortcode( 'today_date', 'get_today_date' );

Wpv-conditional example i want to get:

[wpv-conditional if="( '[cred-post-expiration]' lt '[today_date]' )"]......[/wpv-conditional]

I will be grateful for your help. I can not find a similar solution.

#546748

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well- CRED post expiration time is saved to postmeta key '_cred_post_expiration_time'.

So,

[wpv-conditional if="( '[wpv-post-field name="_cred_post_expiration_time"]' lt '[today_date]' )"]
your content
[/wpv-conditional]

Could you please try above conditional statement and try to resolve your issuel.

#547105

Unfortunately it does not work. The day before the end of post display nothing has changed.

#547212

Minesh
Supporter

Languages: English (English )

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

Can I have problem URL and temporary access details?

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

I have set the next reply to private which means only you and I have access to it.

#547446

Minesh
Supporter

Languages: English (English )

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

Well - I changed the shortcode as given under for 1day check.

function get_today_date() {
global $post;

  $expiration_time = get_post_meta($post->ID,'_cred_post_expiration_time',true);
  $expiration_time =  $expiration_time -  (24*60*60);
  if($expiration_time < time() ){ 
    return 1;
  }else{
    return 0;
  }
}
add_shortcode( 'today_date', 'get_today_date' );

And - within your view used as give under:

<div class="ob-item-date [wpv-conditional if="( '[today_date]' eq '1' )"]expiration-alert[/wpv-conditional]">
		  Zakończenie: <span>[cred-post-expiration format="d.m.y"]</span>
		</div>

If you can check this post - its working:
=> hidden link

#547764

It works as I expected.
Thank you.

Please explain me one more thing: how does the Toolset -> Settings -> Forms -> "Check for expired content:" ?
I set the message for the end of the post display period to 1 day before the automatic expiration date. Post was added on 20.06.2017 07:15 AM. Its display period ends on 20.07.2017 07:15 AM.
If I set the "Check for expired content:" field to "1 day", will the message of the end of the display period be sent on 19.07.2017 07:15 AM or 20.07.2017 00:00 AM?
I want it to be mailed 24 hours before the end, not on the end date of posting.
Can it be better to set "Check for expired content:" as "1 hour"? ...

#547815

Minesh
Supporter

Languages: English (English )

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

Well - as you can see the code:

 $expiration_time = get_post_meta($post->ID,'_cred_post_expiration_time',true);
  $expiration_time =  $expiration_time -  (24*60*60);
  if($expiration_time < time() ){ 
    return 1;
  }

What we have done is we deducted 1 day time from $expiration_time that means it will show notice before 1 day of expiration time.

#547816

Minesh
Supporter

Languages: English (English )

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

Well - as you can see the code:

 $expiration_time = get_post_meta($post->ID,'_cred_post_expiration_time',true);
  $expiration_time =  $expiration_time -  (24*60*60);
  if($expiration_time < time() ){ 
    return 1;
  }

What we have done is we deducted 1 day time from $expiration_time that means it will show notice before 1 day of expiration time.

#547825

Ok, I understand.
Thank you once again