Skip Navigation

[Resolved] Unable to add new custom post type related to another from the front-end

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

Problem:
With a m2m relationship, in the backend when editing one post you can add a related post. This doesn't seem possible on the front end.

Solution:
It currently is not, but will be worked on in the upcoming Forms dev cycle.

Currently you need separate forms to publish posts from either side of a m2m relationship, and then a relationship form to connect them.

Relevant Documentation:
https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/

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

This topic contains 1 reply, has 2 voices.

Last updated by Nigel 6 years, 5 months ago.

Assisted by: Nigel.

Author
Posts
#1087665
Figure1.JPG

Hi,

I have two custom post types:
- Manuscripts
- Authors.

The two types are linked by a many to many relationship.

When I create a new Manuscript post from the BACK-END I can create a new Author post by clicking on the button ‘Add new Author’ (see Figure 1).

However when I create or edit a new Manuscript post from the FRONT-END I am unable to create a new Author post. The Create and Edit Post Forms were create by clicking on ‘Auto-Generate Form’. It looks like I would need to add code in order to add the option to add a new Author from the FRON-END.

Could you please let me know what code I need to add in the credform?

#1088233

Nigel
Supporter

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

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

Hi there

Front-end forms can only do one thing, publish one post or edit one post. It is not possible in a form to create one post to also create a different post. You could add a link that takes you away from the form to a different form to create the second kind of post, but it wouldn't be linked to the first post because that wouldn't have been created yet.

With a one-2-many relationship you can combine creating a child post with assigning the linked parent in one form, that you link to from the parent (so in your case you would publish a manuscript and display it, and its template would include a link to a form to add an author, said form would automatically connect the new author post to the source manuscript).

Unfortunately, with M2M relationships such a workflow is currently not available.

You must connect existing posts with a special relationship form. So you would need forms to publish manuscripts and authors, and another form to connect them.

That is described here (https://toolset.com/documentation/post-relationships/how-to-build-front-end-forms-for-connecting-posts/).

It is on our roadmap to improve these workflows, but for the time being the only alternative would be using the CRED API to connect the posts yourself when using traditional forms to publish manuscripts or authors.