Skip Navigation

[Resolved] How to edit or delete parent post on frontend

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

Problem:
A View queries intermediate posts so as to be able to display fields from a parent post. How to delete relationships or edit a relationship (e.g. assign a different parent)?

Solution:
The context of the View which queries the intermediate posts in the relationship means that you can use the normal cred_delete_post_link or toolset-edit-post-link shortcodes to delete or edit the relationship.

Relevant Documentation:
https://toolset.com/documentation/user-guides/views-shortcodes/#toolset-edit-post-link
https://toolset.com/documentation/user-guides/displaying-cred-editing-forms/
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_delete_post_link

This support ticket is created 6 years, 2 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+01:00)

This topic contains 4 replies, has 2 voices.

Last updated by ScottM9386 6 years, 2 months ago.

Assisted by: Nigel.

Author
Posts
#611585

Hello,

Is it possible for a user on the frontend to change or delete a parent post?

For instance, I have:
SONG (parent) PUBLISHED BY (child) PUBLISHER (parent)
if the PUBLISHER (parent) changes or needs to be removed (because there's no longer a publisher), can that be done on the front-end with a CRED edit link? I know how to set-up an edit link for editing fields, but not for this situation.

Thank you,
Scott.

#611720

Nigel
Supporter

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

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

Hi Scott

You should be able to do this in principle as the cred_delete_post_link shortcode accepts a post parameter which is the id of the post to delete (https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_delete_post_link).

So if a user is viewing a child post, for example, the template for the child post can include that shortcode and set the post id using the wpv-post-id shortcode with the id attribute to specify the parent (https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-id).

For editing, I'm not sure what you mean, you want to assign a different parent or you want to make changes to the parent post?

To assign a different parent you would edit the child post itself with a CRED edit form.

To make changes to the existing parent, it is a bit trickier.

You use the toolset-edit-post-link shortcode to generate the edit link, but it doesn't take any parameters to specify the post (https://toolset.com/documentation/user-guides/views-shortcodes/#toolset-edit-post-link). You link to the template which actually contains the form (the cred_form shortcode). That does let you specify the post (https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_form).

I would try creating a specific content template to hold the cred edit form to edit the parent. I'm not sure but I think when you link to that from the child post the context will be the child post, so you should be able to employ the same technique as above using the wpv-post-id shortcode with id attribute to set the post attribute of the cred_form shortcode to specify the parent.

There's only one way to know, which is to try it.

Can you try it and if it doesn't work let me know and I'll investigate further?

#611889

Thanks Nigel,

I will try. The problem is the child is an unseen intermediary post that cred generates an auto title for.
Maybe I could of/ should of set this up differently, but I think I determined - after countless hours, that this was the best way for my particular project.
I'll explain a little:
Song (parent) intermediate (child) Publisher (parent) - (needs to be many to many)
There are 3 forms
1. A form to create the Song with fields for meta data
2. A form to create the Publisher name
3. A form to attach the created song to the publisher (this form is generated from the child, as it has to be, and doesn't contain a title field, which is why the intermediary child post title gets auto generated) The reason for this is so that in this form the user can just select the track in a dropdown and the publisher in a dropdown and hit submit and they are linked.

Then, to view this data I have a template which shows, on one page, the Song with fields and (with a view in the same template) the parent relationship.
So you see, the child is really just a placeholder that works in the background and never gets seen by the user.
It doesn't seem an ideal solution.

Frankly, if I can't get toolset (which is a great plugin!) to do what I need I might have to try something else.
You guys are great though, and I very much appreciate the support.

If you have any ideas about setting this up differently, that would be appreciated.

Thank you!
Best,
Scott.

#612138

Nigel
Supporter

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

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

Hi Scott

I assume you have a template for displaying a song post, and this template displays the connected publisher using a View which queries the intermediate post type and displays fields from the parent publisher using the id attribute, e.g.

Publisher: [wpv-post-title id="$parent"]

Now if your user wants to delete the publisher from the current song, they don't want to delete the publisher post itself, they want to delete the relationship, i.e. the intermediate post.

Well that View which is used to display the parent post fields is querying the intermediate posts that store the relationship, so that's the post you want to delete (or edit).

So in the Loop Output section of that View you already have the correct context for the cred_delete_post_link or the toolset-edit-post-link shortcodes, to either delete the relationship or to edit it (e.g. change to a different publisher).

So unless I'm missing something, it's maybe not so complex after all, though I can see how you might be going round in circles with this.

#612631

ok

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.