Skip Navigation

[Gelöst] The best way to allow author to edit his post?

This support ticket is created vor 7 Jahren, 7 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

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

Zuletzt aktualisiert von Christian Cox vor 7 Jahren, 7 Monaten.

Assistiert von: Christian Cox.

Author
Artikel
#512094

Hello

I have created a content template and users use cred to send their posts.

1. What is the best way to allow a user to edit his post?

2. Can I limit the time he can edit his post? For example, he has 3 days to edit the post since it was published.

Thanks

#512238

Hi, I'll try to help with your questions.

1. What is the best way to allow a user to edit his post?
I think it's a good practice to include an "Edit post" link on the single post page, as well as on any post lists. First, create a CRED edit post form for the posts created by your Users. In your single post content template, include a link to this CRED edit form. You can use conditional HTML output to show the edit link to only the author of the post. If you show your users a list of their own posts, you could include the same CRED edit form link for each list item. Again, use conditional HTML output to hide the link from everyone except the post author.

2. Can I limit the time he can edit his post?
You could accomplish this using conditional HTML. If the publish date is more than 3 days ago, you can hide the Edit links you added in question 1. You could also wrap your CRED edit form in similar conditional HTML output that hides the entire edit form if the publish date is more than 3 days past, or if an unauthorized user (not the author) tries to access the post edit page.

Let me know if I can help clarify any of this further for you.

#512245

> Again, use conditional HTML output to hide the link from everyone except the post author.

What happens if another user manages to get the link? Will he be able to edit the post?

Thanks

#512261

It's possible, depending on how your users are set up. You can prevent this in a couple of ways. There is a simple approach and a more complex approach.

- Simple approach: Use conditional HTML output to hide the entire CRED form from users who are not the post's author. This is a simple way to prevent the form from rendering. The conditional will look something like this:

[wpv-if evaluate="'[wpv-current-user info='id']' = '[wpv-post-author format='meta' meta='ID']'"]
...your form goes here
[/wpv-if]

- More complex approach: Use Toolset Access to define much more specific rules about who can edit these custom posts, based on user roles, post type, post groups, and other factors you define. This is the more robust solution that can help you manage permissions for many aspects of your site. Documentation for Toolset Access is available here:
https://toolset.com/documentation/user-guides/setting-access-control/