Skip Navigation

[Resolved] How to create a CRED edit link without Layouts or Content Templates

This thread is resolved. Here is a description of the problem and solution.

Problem:
How to create CRED edit links with CRED alone?

Solution:
CRED Edit Links are not available with CRED alone.
Toolset Views is required to have them working.

However you can insert the Edit Form itself, in the single Posts you need to Edit, or, you can insert the Edit Form in any other post, and pass an ID to edit the Post you want by adding the ShortCode attribute "post=" where this is a numeric ID of the post to edit.

This support ticket is created 6 years, 10 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
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Tagged: 

This topic contains 1 reply, has 2 voices.

Last updated by Beda 6 years, 10 months ago.

Assisted by: Beda.

Author
Posts
#612252

Hello,

Is there a way to put code in a single-whatever.php template file to a CRED edit form version of the page without using Layouts or Content Templates? I have a website where I am attempting to NOT use Views (no offense, it is a great plugin that I use often, but the requirements of this project are unique).

I have used Types to create custom post types, and I've used CRED to make Add and Edit forms for those Post types. But I have been making all my single and archive pages the old fashioned way in php files, so I haven't been using Views on this project. I'd like to put a link in the single php file for a custom post type, and have it only show when the current user is the author of the page. I know how to do the logic for only showing something to the rightful author of the page, but what is the code for outputting the CRED form Edit link that will show the CRED edit form for that page when they click on it? I haven't been able to find any documentation for what that link looks like outside of the Views environment, or if it is even possible to do that.

Please advise.

Thanks!

#612356

CRED Edit Links are not available with CRED alone.
Toolset Views is required to have them working.

However you can insert the Edit Form itself, in the single Posts you need to Edit, or, you can insert the Edit Form in any other post, and pass an ID to edit the Post you want by adding the ShortCode attribute "post=" where this is a numeric ID of the post to edit.

So if you are doing this with CRED alone, you can as example do_shortcode('[cred_form form="your_form"]'); in a PHP template of the current post.

Or, you can craft a link to a single page, that you insert in your single posts template with PHP/HTML:
Edit this post

Of course above is a dummy code.
$post_id needs to be a dynamic PHP variable of the Post ID you want to edit (usually, current post).
?post_to_edit= can be anything you like, as long after this matches your ShortCode to get the URL parameters (see below).

Then, you need to craft a Custom ShortCode to get the URL parameter (Views has this, but since you are not using Views, you need to craft your own).

Then, this ShortCode should return exactly only the URL parameter term:
your post ID you want to edit.

After, you can insert your CRED form to that Page you call, and in the CRED ShortCode "post=" attribute you insert the Custom ShortCode that returns the ?post_to_edit value (which is the post ID).

This will allow you to edit all posts with the CRED Edit form sitting on a single page.