Tell us what you are trying to do?
I have a form which sets post expiration. I want to display the post expiration date on the front end.
Is there any documentation that you are following?
https://toolset.com/course-lesson/setting-up-automatic-post-expiration/
There doesn't seem to be any documentation on how to display the post expiration date, e.g. in a content template... Please advise?
Forgot to ask also - can this field be edited with CRED on the front-end?
Hello,
Q1) display the post expiration date on the front end
It is possible to display the post expiration value with shortcode, for example:
[cred-post-expiration format="m/d/Y"]
Q2) can this field be edited with CRED on the front-end?
Yes, it is possible, see below sandbox website:
Login URL: hidden link
1) Dashboard-> Toolset-> Post Forms, click button "Manage non-Toolset Post Fields"
hidden link
find and enable the hidden field "_cred_post_expiration_time"
2) In your post form for editing post:
hidden link
You can display above custom field,
3) Test it in frontend:
hidden link
It works fine
Hi Luo,
Q1-Thank you for the information - apologies, I missed cred-post-expiration in the Forms documentation.
Q2- I have taken a look at your sandbox, then tried to follow the same in my admin, but the _cred fields don't appear in the list (see attached - I checked against posts and pages and took the screenshot for the latter, hence it showing there).
2.1 The expiration event doesn't seem to be firing, despite having set the schedule to 'every 5 minutes'. I've installed WP Crontrol to take a look at crons (assuming this is what is used to schedule expiration processes) and there doesn't seem to be an entry in the list, either for schedule or events. Our host disables WP-CRON and uses the hosting cron to run events, but events are running successfully for AutomateWoo and other plugins...
For info, screenshots attached show expiration settings in Toolset > Settings > Forms, and an example post whose expiration was set via a form submission - expiration in the past, but Post Status isn't changing to 'Trash'.
Q2) I can not reproduce the same problem, it works fine in the sandbox website, can you reproduce the same problem in above sandbox website?
Are you using the latest version of Toolset plugins? you can download them here:
https://toolset.com/account/downloads/
According to our support policy, we prefer one ticket one question, for other new issues please check the new thread here:
https://toolset.com/forums/topic/post-status-isnt-changing/
Hi Luo,
Plugins are all up-to-date.
I have gone looking for the same in another site, and cannot see the _cred_post_expiration_time in non-Toolset post fields.
This other site is on GeneratePress with very few plugins installed, so it seems unlikely to be a plugin conflict.
Is there something else I need to enable in order to see the field...?
I have also created a blank site to test this on, and cannot see that field. I can provide you with Admin login to take a look if you want.
OK, please provide your blank website credentials in below private message box.
Thanks for the details, I am checking it in your website, will update here if find anything
The problem is, in the Dashboard page:
hidden link
The select field "Select a post type" does not outputs post types created with Toolset Types by default, it works for post types created with other plugins.
In your case, you can try these:
Edit Toolset Forms plugin file: cred-frontend-editor/library/toolset/cred/embedded/models/Fields.php
hidden link
Change line 105 from:
$wpcf_custom_types = get_option( 'wpcf-custom-types', false );
To:
//$wpcf_custom_types = get_option( 'wpcf-custom-types', false );
Then try again:
hidden link
You will be able to add the custom field "_cred_post_expiration_time", and add it into Toolset post forms.
After that you can restore the "Fields.php" back.
Hi Luo,
Thanks for that. I've made the change you suggested to my test site. I note that the change works for a post type of 'Post', but when I change the form to create a CPT ('Expiring Thing'), the field does not work. I don't get the option to add it in the form creation wizard, and if I add it manually in expert mode, the front end throws an error, as before.
Sorry for the delay answer, I have tried it again in below sand box website, it works fine:
Login URL: hidden link
1) Create a custom post type "Expiring Thing"
hidden link
2) Comment out line 105:
hidden link
3) Test it again:
hidden link
I can select custom post type "Expiring Thing" correctly, can you reproduce the same problem in above test site?
Hi Luo,
Thank you for the reply. I've revisited this, and I hadn't understood what you were achieving with the commenting-out of line 105 - after commenting out line 105, I needed to go back to Post Forms > Manage non-Toolset Fields, select 'Expiring Things' and make sure to add the expiration time.
For completeness, here is the sequence I have documented:
1. Comment out line 105 of Toolset Forms plugin file: cred-frontend-editor/library/toolset/cred/embedded/models/Fields.php
2. Go to Toolset > Post forms <scroll down to> 'Manage non-Toolset Post Fields with Toolset Forms' and select the button
3. Show fields for 'Expiring Thing' > Include Hidden Fields > +Add _cred_post_expiration_time as Date. It should look like the attached image.
4. Reactivate plugin line 105.
Now the _cred_post_expiration_time is available for use in Expiring Thing forms.
Sorted, thank you.
My issue is resolved now. Thank you!