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