Skip Navigation

[Resolved] How can a edit CRED form shortcode in a page dynamically receive Post ID

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

Problem:

The problem is that the customer had a CRED Edit form embedded on a separate page and wanted to use that page to edit all his posts.

Solution:
I managed to get this to work on my end, so what is needed is for you to follow the steps below.

First you need a way for the edit form shortcode to get the id of the post to edit from the url. To get this you will need to use the [wpv-search-term] shortcode.

So you should have a setup like this.

[cred_form form="Edit Post" post="[wpv-search-term param='post']"]

The next thing is to have your edit form link to the page where the form is embedded so your setup should be similar to.

<a href="http://localhost:8888/layouts_demo/uncategorized/test/?post=[wpv-post-id]">

Relevant Documentation:

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.

Tagged: 

This topic contains 5 replies, has 3 voices.

Last updated by ahmedh 5 years, 8 months ago.

Assigned support staff: Shane.

Author
Posts
#362835

Hello,

From a VIEW loop I'm passing a query string parameter (Post ID)
<a href="hidden link;">EDIT</a>

to a page that has a CRED edit form with the form shortcode such as:
[cred-form form="Edit Post"]

Your documentation has only an example of hard-coded post ID:
[cred-form form="Edit Car" post="145"]

I can successfully get the url query string to display the post id for example: ?post=145

But how do I dynamically pass the parameter value into the form's shortcode so that this specific post (id=145) is edited?

#362860

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Screen Shot 2016-01-28 at 3.32.11 PM.png

Hi Allan,

Thank you for contacting our support forum.

From your post I gather that you want to place an edit post link beside each post in the view loop correct?

If so then when you click the CRED Forms button you will be presented with a popup like the one in my screenshot.

All you need to do is select the options that I have and the shortcode will generate a link for the post being displayed in the current loop, so you do not need to pass the ID of the post manually.

Please let me know if this helps.

Thanks,
Shane

#362942
[SCREENSHOT 3] The Wordpress PAGE with the embedded form shortcode.PNG
[SCREENSHOT 2]  The Form by itself with Sidebars.PNG
[SCREENSHOT 1]  The View Page with EDIT & DELETE links in Loop.PNG

Hi Shane, what I meant was that the loop/grid [SCREENSHOT 1] will have an edit link to a new PAGE that has the CRED edit form embedded as a shortcode [SCREENSHOT 3] , NOT A LINK TO THE FORM ITSELF in a new window [SCREENSHOT 2].

As you notice in screenshot 2 (the form window) you get these two left and right sidebars. Whereby in screenshot 3 (the page window) I have made the Page Attributes > Template as "Full-width" to be consistent with the rest of the CMS interface. In the form window the left sidebar displays post author meta which is totally unnecessary, irrelevant and confusing to the user.

Like I mentioned in my first message I know how I can SEND a querysting from the edit link in the view by using an href anchor hidden link; from the view's loop.

What I want to know is what can be done on the receiving end, that is the PAGE that has the embedded shortcode for the edit form. How can I dynamically pass the querysting URL parameter (?post-id=1234) from the previous page into the form shortcode to be placed in the post id parameter of the form's shortcode?

This [cred-form form="Edit Car" post="145"] -----> becomes -------->

Something to that effect: [cred-form form="Edit Car" post="%post-id%"]

#363145

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Allan,

Thank you for the clear explanation.
I managed to get this to work on my end, so what is needed is for you to follow the steps below.

First you need a way for the edit form shortcode to get the id of the post to edit from the url. To get this you will need to use the [wpv-search-term] shortcode.

So you should have a setup like this.

[cred_form form="Edit Post" post="[wpv-search-term param='post']"]

The next thing is to have your edit form link to the page where the form is embedded so your setup should be similar to.

<a href="<em><u>hidden link</u></em>">

Please let me know if this helps.

Thanks,
Shane

#363150

Exactly what I needed, and it worked like a charm.

Thanks a bunch Shane.

#576631

Hello,

I have a similar issue as I want to add an edit link into the single post that edits in a separate page that has a cred edit form.

Please help.

Thank you,

Ahmed