Skip Navigation

[Resolved] CRED Expiration date doesn´t work

This support ticket is created 4 years, 9 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by Luo Yang 4 years, 9 months ago.

Assisted by: Luo Yang.

Author
Posts
#1612873
postform.jpg

Hi,

could you please help me with small issue in solution with post expiration date?

I don´t know why but a few weeks sooner it works like a charm but it´s broken right now and i would like to know where i did some mistake.

I had a post form where is setup expiration date from timestamp + xxx days. I would like to have a post form which would be only till this date (+180 or 365). The IDs of form data are correct.

I can´t show in View by shortcode [cred-post-expiration id="[wpv-post-id]" format="d-m-Y"] the date of expiration.

Functions.php

/** Form expiration date by product id řešení*/
add_action('cred_save_data', 'my_save_data_action',999,2);
function my_save_data_action($post_id, $form_data){
    // if a specific form
    if ($form_data['id']==4681){
 
        //get the value from the field as it appears in the post with the ID from above and assign it to a variable
        $product_id = get_post_meta($post_id, 'reklama', true);
         
        if($product_id == 4677){
                $timestamp = current_time('timestamp') + 180 * DAY_IN_SECONDS;
     
            }else if($product_id == 4682){
                $timestamp = current_time('timestamp') + 365 * DAY_IN_SECONDS;
          
            }
        update_post_meta($post_id, '_cred_post_expiration_time',  $timestamp);
    }
      if ($form_data['id']==4925){
 
        //get the value from the field as it appears in the post with the ID from above and assign it to a variable
        $product_id = get_post_meta($post_id, 'reklama', true);
         
        if($product_id == 6493){
                $timestamp = current_time('timestamp') + 90 * DAY_IN_SECONDS;
     
            }else if($product_id == 6494){
                $timestamp = current_time('timestamp') + 180 * DAY_IN_SECONDS;
          
            }
        update_post_meta($post_id, '_cred_post_expiration_time',  $timestamp);
    }
   }

In post form ID 4681:

[cred_generic_field type='select' field='reklama' class='form-control']
{
"required":0,
"persist":1,
"default":["4677"],
"options":[{"value":"4677","label":"4900,- kč - zvýhodnění na 6 měsíců"},{"value":"4682","label":"8490,- Kč - zvýhodnění na 1 rok"}]
}
[/cred_generic_field]

View to show on users front-end date of expiration:

<td>[wpv-post-title]</td>
<td>[wpv-post-date format="d-m-y"]</td>
<td>[wpv-conditional if="($(wpcf-clanek-placeny) eq '1' )"]<i class="fa fa-check"  style="color:green" title="Zvýhodněno"></i> <a style="font-family:quicksand;color:white;font-size:10px;"> do [cred-post-expiration id="[wpv-post-id]" format="d-m-Y"]</a>[/wpv-conditional]
  [wpv-conditional if="($(wpcf-clanek-placeny) eq '2' )"]<i class="fa fa-times-circle" style="color:green" title="Bez zvýhodnění"></i>[/wpv-conditional]</td>
<td>[wpv-conditional if="('[wpv-post-status]' eq 'publish')"]<i class="fa fa-check-circle"  style="color:green" title="Schváleno"></i>[/wpv-conditional]
[wpv-conditional if="('[wpv-post-status]' eq 'pending')"]<i class="fa fa-times-circle" style="color:red" title="Čeká se na schválení"></i>[/wpv-conditional]</td>
#1613547

Hello,

It is a custom codes problem, please provide a test site with the same problem, fill below private message box with credentials, also point out:
- The problem page/post URL and form URL
- Where I can edit your custom PHP codes

I need a live website to test and debug, thanks

#1613601

I don't see your website URL in the private message box:
https://toolset.com/forums/topic/cred-expiration-date-doesnt-work/#post-1613597

Please share the website URL and point out the problem post/page URL, where I can see the problem:

I can´t show in View by shortcode [cred-post-expiration id="[wpv-post-id]" format="d-m-Y"] the date of expiration.

I will check it in tomorrow morning, thanks

#1618621

Hi Luo,

i updated private message - you can find more details there.

Thank you.

#1619313

Thanks for the details, I am checking it in your website, will update here if there is anything found

#1619337

I assume we are talking about the page:
hidden link

And the Toolset form:
hidden link
Please check it, in section "Form Editor", you are using below generic field shortcode:

[cred_generic_field type='select' field='reklama' class='form-control']
{
"required":0,
"persist":1,
"default":["4677"],
"options":[{"value":"4677","label":"790,- kč - zvýhodnění na 3 měsíce"},{"value":"6494","label":"1590,- Kč - zvýhodnění na 6 měsíců"}]
}
[/cred_generic_field]

But in your PHP codes:
hidden link
The product IDs are 4677 and 6494, line 236 ~242, you are using below PHP codes:

        if($product_id == 6493){
                $timestamp = current_time('timestamp') + 90 * DAY_IN_SECONDS;
     
            }else if($product_id == 6494){
                $timestamp = current_time('timestamp') + 180 * DAY_IN_SECONDS;
          
            }

They are different product IDs: 6493 and 6494

I have done below modifications in your website, edit the functions.php. replace line 236 from:
if($product_id == 6493 ){

To:
if($product_id == 4677){

Tested it again in front-end:
hidden link
I can see it works fine. can you confirm it? thanks