Having reviewed the previous ticket, on re-reading it I realised that we are not talking about a custom field at all, rather the standard expiry date, which is set when you choose
"Set expiration date for post created or edited by this form" in the following Toolset forms (we want it set for to 185 days)
Post Form - New Nanny Ad (ID: 921)
Post Form - New Nanny Ad - Unverified Nanny (ID: 23430)
We have exactly the same options selected on our forms in dev, where it appears to work fine. It's just in production where it is not working correctly.
Can this please be investigated as to why the standard Expiry Date field is not being populated correctly on creation of a Nanny Ad record via the Toolset Forms mentioned.
WP Adminer is available on the production site to query the database, but please do not change anything without our consent as this is a production site.
Hello. Thank you for contacting the Toolset support.
Can you please share access details for frontend user and admin for your test site where you claim its working. I'll require to review your setup why its working on your Dev site but not on your production site.
Have you added any custom code related to those forms on Devs site but not on your production site?
*** 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.
I've tried to add the following post on your live site from the frontend using the user you shared: nativenanny2@hotmail.com
=> hidden link
I can see that the post expiration date is set correctly.
Even I checked the database and with database as well I can see the post expiration date is set correctly. Please check the following screenshot: hidden link
I'm not sure in what term you say that the post expiration date is not set. Do you have exact steps I should follow to reproduce the issue?
As I stated in the original ticket, it was not ALWAYS being set correctly. You can see this for lots of Nanny Ads in the Nanny Ads screen in the furthest right column.
For your ad, it appears you were lucky this time. Compare with (production) Nanny Ad, ID 33145 (please don't edit it):
There you can see in the top section "Nanny Ad expiration" that the expiry date appears to be set, however in the section "Field Group for Nanny Ads" the same Ad appears blank.
Nanny Ads created with the form:
Post Form - New Nanny Ad - Unverified Nanny (ID: 23612)
are not included in the custom code snippet:
preserve-ad-expiry-date
I think the id 23612 just needs to be added to the array, like this, right?
(I'm gonna try this now on dev.native-nanny.de, but could you please confirm I am doing it right?)
add_action('cred_save_data', 'populate_nanny_ad_expiry',11,2);
function populate_nanny_ad_expiry($post_id, $form_data)
{
// Post Form - New Nanny Ad (921)
// Post Form - New Nanny Ad - Unverified Nanny (ID: 23612)
$forms = array( 921, 23612 );
$slug = 'wpcf-nanny-ad-expiry';
if ( in_array( $form_data['id'], $forms ) )
{
// copy the original expiration timestamp into a hidden custom field
// for future reference, since original timestamp is reset upon expiry
$expiry = get_post_meta( $post_id, '_cred_post_expiration_time', true );
if( $expiry && $expiry !='0' )
{
update_post_meta( $post_id, $slug, $expiry );
}
}
}
So, it looks like the original expiry date is getting set correctly for all the Ads. This makes sense. The code was written at a time before the introduction of the Post Form - New Nanny Ad - Unverified Nanny (ID: 23612).
However, we would need to update the Expiry Date field with the same value from the original expiry date set for all those Nanny Ads which don't have it. What would be your recommendation for doing this? Just by some SQL statement on the database? Is that permissible or will that screw something else up?
You will have to write your own script to update the custom field value based on your requirement. Such custom script falls outside the scope of our support policy. You can always contact our certified partners for such custom programming work.