Skip Navigation

[Gelöst] Post expiry date

This support ticket is created vor 2 Jahren, 8 Monaten. 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.

Heute stehen keine Supporter zur Arbeit im Werkzeugsatz-Forum zur Verfügung. Sie können gern Tickets erstellen, die wir bearbeiten werden, sobald wir online sind. Vielen Dank für Ihr Verständnis.

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

Supporter timezone: America/Jamaica (GMT-05:00)

Dieses Thema enthält 22 Antworten, hat 3 Stimmen.

Zuletzt aktualisiert von leilaG vor 2 Jahren, 7 Monaten.

Assistiert von: Shane.

Author
Artikel
#2336915

Minesh
Supporter

Sprachen: Englisch (English )

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

Can you please share live site access details and setup a test page where you added your form, maybe you would like to create another form so we can test it.

*** 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 have set the next reply to private which means only you and I have access to it.

#2349651

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Leila,

Thank you for the login details.

I've submitted a test job that should expire on April the 27th.

Once the CRON job runs I will check and see what happens to the post.

Thanks,
Shane

#2349725

Hi Shane, I checked and there is no test that has been submitted or that is live.

#2350719

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Leila,

I did some digging into this a bit more for you and it appears that the post expiration information isn't being modified in the database.

Can you let me know where you've added the code for the post expiration ?

I will like to do a trace through to see where it is failing to set the value.

Thanks,
Shane

#2351931

Hi Shane,

The below code is in the functions.php file

//Jobs form set expiry date

add_action('cred_save_data', 'func_set_custom_post_expiration_date_time',10,2);
function func_set_custom_post_expiration_date_time($post_id, $form_data){
// if a specific form
if ($form_data['id']==4896){

$expiry_date = $_POST['expiration-date']['timestamp'];
update_post_meta($post_id, '_cred_post_expiration_time', $expiry_date );
}
}

#2352021

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Leila,

Thank you after several tests I was able to get this to work now. The correct code should be.

add_action('cred_save_data', 'func_set_custom_post_expiration_date_time',10,2);
function func_set_custom_post_expiration_date_time($post_id, $form_data){
    // if a specific form
    if ($form_data['id']==4896){
		
		
        $expiry_date = $_POST['expiration-date']["datepicker"];
            update_post_meta($post_id, '_cred_post_expiration_time', $expiry_date );
    }
}

The problem was that you were selecting the wrong identifier for the expiration-date field which caused the custom field for the expiration date not to get update.

This should now be resolved.

Thanks,
Shane

#2352025

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Leila,

On further checks I noticed that it was still not working.

This lead me to believe that the value of the expiration is being set much later by Toolset forms than the point where the hook is setting the date. This means that our date is being overwritten by the default information.

Now I used a hook that fires later than the cred_save_data hook and this works. I've tested it and the date value is now being set correctly.

add_action('cred_submit_complete', 'func_set_custom_post_expiration_date_time',10,2);
function func_set_custom_post_expiration_date_time($post_id, $form_data){
    // if a specific form
    if ($form_data['id']==4896){
		
		
        $expiry_date = $_POST['expiration-date']["datepicker"];
            update_post_meta($post_id, '_cred_post_expiration_time', $expiry_date );
    }
}

PLease go ahead and test this and let me know if the date is being set for you as well.

Thanks,
Shane

#2352647

Hi Shane, that's great! Tested and it is now showing the correct expiry date 🙂
Thank you for your help and support.