One classifieds post is valid for 21 days.
An email is automatically sent to the post owner that it expires in 24 hours.
I would like to have a link to the edit form in that mail.
I have prepared an additional form that after saving, will extend the offer for another 21 days.
Unfortunately, the code that I get from Fields and Views in Notification e-mail body does not work:
[wpv-post-body view_template="szablon-przedluzenia-oferty-szkola"]
You can't insert the form itself into an email notification body, you should be inserting a link to the edit form (although you actually specify the template which hosts the form) using the toolset-edit-post-link shortcode.
I haven't tried whether it will work correctly in the context you describe (an email notification). Please try it and let me know whether you succeed or not.
Thanks for fast reply and for the hint!
Yes, it was a silly mistake 😀
I have pasted this link from Fields and Views automatically.
Now it works, I have prepared a speciall link, but I have one problem.
But at the beginning I will share how I made this link.
1. Make a form for renew post.
2. Make Content Template for "editing post" with this form.
3. In mail body paste link: Renew ad
It works almost perfect.
Link is OK but if the post will be moved to trash link is wrong.
It looks like:
mydomain/slug__trashed/?content-template-id=226
I have made a rule in htaccess file:
RewriteCond %{QUERY_STRING} __trashed
RewriteRule .? hidden link [R=301,L]
where "ogloszenie-wygaslo" is the page with notice for users.
Unfortunatelly after click in that link URL looks: hidden link
and shows info "The form type and entry type do not match"
The system attaches: ?content-template-id=226
Is there any way that the system will not modify this address?
Or maybe there is another way to make special info when the post is in the trash?
Ideally, it would be if it was possible to create a link, after which the ad will be automatically extended.
But this solution is probably not in Toolset?
It sounds like you send a reminder email 24 hours before a post expires (and I guess when the post "expires" it goes to trash).
So, when the email is actually sent, the link should be correct, right? As the status of the post at the time the email is sent is published.
And your problem is that, if people click the link more than 24 hours after it has been sent, by then the post is trashed, and so the link (which was the correct link), will no longer work.
If that is the case I think the fundamental problem is that you cannot edit a post that is in the trash with a front-end form, regardless of the URL.
For this scenario you would need to change your forms so that when a post expires it goes to draft status instead of trash, then it can be edited, and your links should work.
(You might then need to run a scheduled script to delete old draft posts.)
- display something instead of the normal 404 if a post is in the trash
You would need to write some custom code for that which intercepts loading the theme's normal 404.php template, checks if the post that was trying to be displayed was in the trash, and does something else instead.
I can't really help you with custom code such as that, but I found this which might help get you started on coding such a solution. (You might, alternatively, create a modified 404.php template in a child theme which includes some similar logic.)
- create a link to extend the expiration time with one click
To update the expiration time the post must be edited. The "Toolset" way to do that is to display a post edit form with a submit button which the user clicks. It might be helpful to know that you could create an edit form which included the submit button and nothing else, so the user wouldn't even know they were editing the post. But you have to display the edit form the same way as normal, so the link would still take them to a page (the post URL plus parameter that specifies the template which contains the form) which showed a button to be clicked and not much else.
(You would create a second edit form for this purpose which you would have to add to its own template for display.)
2. In the form for prolonging the ad, I left only the button and it works great without classifieds fields.
I added only one message and this all together gives a super clarity for user.