Skip Navigation

[Resolved] Link to edit renew post form doesn't show in email body

This support ticket is created 5 years, 11 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 6 replies, has 2 voices.

Last updated by tomaszB-4 5 years, 10 months ago.

Assisted by: Nigel.

Author
Posts
#1194189

Hello!

I have Custom Post Type: classifieds.

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"]

The e-mail is empty in this place.

How can I insert such a link?

#1194204

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Tomas

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.

See https://toolset.com/documentation/user-guides/cred-shortcodes/#toolset-edit-post-link

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.

#1195027

Hi Nigel!

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?

thanks again!

#1195347

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Tomas

Can you just clarify for me when this goes wrong.

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.)

Let me know if I have misunderstood.

#1196890

Thanks Nigel, it was helpful!
I have changed expired posts to be drafts and now they can be edited even after the expired time.

But I'm curious if there is an opportunity to do:

- If the CPT post (classifieds) is in the trash, can the user see different info on the its page than the standard 404 page?

- Is it possible to create a unique link for the user, so he with one click will extend the expiration time of his post?

regards!
Tomasz

#1197186

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Tomasz

- 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.)

#1197750

Many thanks for the hints Nigel!

1. I will be modifying page 404 soon.

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.

thanks again!
Tomasz