Skip Navigation

[Resolved] CRED forms for a parent CPT and its child CPTs

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

Problem: I would like to create CRED forms where a parent CPT can be edited, and child CPTs for that parent can be added or modified.

Solution: Create separate CRED forms to manage the parent CPT, and to create child CPTs. Use the CRED create child link shortcode to link to the child CRED forms. Hide the parent selector using conditional HTML when the parent parameter is present in the URL.

Relevant Documentation:
https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#612833

Hi
I read a lot of articles on your site but I am very confused, here is my problem
I have a post type theater-company
I have a post type shows which is the child of the post type theater-company.
In the wordpress admin for the post type theater-company, I can handle adding and editing shows and company information.

I would like to do the same thing with a clean online form for each company.

What is the right procedure to follow
Thank you

Guyk

#612982

Hi, you can use a CRED form to create child posts from the front-end of your site. You can add that form to the single post of each Theater Company, or you can place that form on another page. Here's how I would start:
- Create a New Post CRED form that creates "Show" posts. More info about this here: https://toolset.com/documentation/user-guides/cred-forms-for-child-content/

- Insert this form in a Content Template or Layout assigned to the Theater Company post type. When you load the Theater Company single post, the form will be displayed.

- The form includes a select field that allows you to choose a parent Theater Company for the new Show. If you want to hide this field and automatically select the current Theater Company, edit the CRED form and wrap the parent field in a hidden div. Use the wpv-post-id shortcode with the $current_page operator to preselect the current page as the parent post in the "value" attribute:

<div style="display:none;">
  [cred_field field='_wpcf_belongs_theater-company_id' value='[wpv-post-id id='$current_page']' select_text='--- not set ---' class='form-control' output='bootstrap']
</div>

Your cred_field shortcode may be different if you have different post type slugs. The key is in the format "_wpcf_belongs_" + parent post type slug + "_id". So if your Theater Company post type slug is "theater-co" then yours should be "_wpcf_belongs_theater-co_id".

- Once you have this form working on the Theater Company page, we can work on moving it to a different location if you'd like. Let me know how far you are able to get and we can go from there.

#613479

Hi Christian,
I can not do it and want to do the operation twice

In this page he can edit the shows directly
http: // localhost: 8888 / YES / company / antre2reves /

and in this page
hidden link
you can try with Archipel
if I am a theater company and connect me with my IDs I can complete my shows and choose my name from a drop down menu.
I would like if the company is connected it can directly fill its shows without the drop down menu

Thanks
Guyk

#613497

I can not do it and want to do the operation twice
Okay we are here to help, but we are not here to build something for you. Please tell me exactly where you are having problems and I can offer guidance. If you need someone to build a site for you, I recommend checking out our contractors portal to connect with a professional developer: https://toolset.com/contractors/

In this page he can edit the shows directly
http: // localhost: 8888 / YES / company / antre2reves /

I can't see your localhost, sorry!

and in this page you can try with Archipel
I'm only able to see a login form here. I will activate private reply fields here so you can share a login with me if you want me to see this.

#613863

Sorry but these login credentials do not work for me. Can you please double check? Is there an IP restriction or other security plugin in place? I will activate private reply fields again so you can provide updated login credentials if necessary.

#613904

Okay the login works for me now, thank you. Maybe I made a typo earlier.

When a theater company connects with his credentials, it must be able to edit the record and add or edit shows
I think you are saying you want to allow Users who are associated with each Company to edit that Company and manage its Shows. I have some additional questions:
- Can a single User access more than one Company?
- How are Users associated with Companies? There are two basic options - use a custom field, or use custom Roles in Access.
- Custom Roles are easiest to use with Access and CRED, but only one Role is allowed per User. So if a single User must have access to more than one Company, Custom Roles may be difficult to implement.
- A custom field can be added to a User's profile, where you can select a Company ID for each User. This is an easy way to associate Users and Companies.

#613928

- Can a single User access more than one Company?
no

- How are Users associated with Companies? There are two basic options - use a custom field, or use custom Roles in Access.

the site administrator creates a unique subscriber account for companies

#613969
Screen Shot 2018-02-07 at 4.49.50 PM.png

Okay I looked at your Layout Pour les Compagnies and I see that a lot has beed done already! I fixed two problems. See the attached screenshot.

I replaced the edit post link and conditional code with this:

<h5>[toolset-edit-post-link layout_slug="modifier-une-compagnie" ]Edition[/toolset-edit-post-link]</h5>
[/wpv-conditional]

I checked the box "Désactiver les paragraphes automatiques" so this problem will not occur in the future. The paragraph tags inserted in your content broke the shortcodes. Now, "Edition" is a link to the Edit CRED form here:
hidden link
hidden link

Next, I created a new Child CRED post link in the Visual Editor cell at the bottom of the Layout. Your old code was:

<p>[cred_link_form form="spectacles" text="Edit %TITLE%" target=""]</p>

I created a new child post form link. In the Visual Editor cell, click "formulaires CRED", then "Créer un lien de publication enfant", then in the "Page that contains the form" I selected "Ajouter un spectacle", and "Définir le parent en fonction du contenu affiché actuellement". The new link shortcode is:

<p>[cred_child_link_form form="7224" parent_id="-1" text="Create new" target="_self"]</p>

Now you can see a "Create new" link here: hidden link

Please take a look and let me know what you think so far.

#614258

Thanks a lot Christian

Two more question
To add a show, How to connect this new show directly with company1 without having to choose from the drop-down menu(parent)

At the moment if I am logged in as a company1 I can add a show to compagnie2 (

How to directly modify already existing shows in the compagnies list?
hidden link

#614428

To add a show, How to connect this new show directly with company1 without having to choose from the drop-down menu(parent)
Use conditional HTML to hide the form group when the URL parameter parent_compagnie_id is present:

    [wpv-conditional if="('[wpv-search-term param='parent_compagnie_id']' eq '' )"]
	<div class="form-group">
    [/wpv-conditional]
    [wpv-conditional if="('[wpv-search-term param='parent_compagnie_id']' eq '' )" evaluate="false"]
	<div class="form-group" style="display:none;">
    [/wpv-conditional]
		<label>Parent compagnie</label>
		[cred_field field='_wpcf_belongs_compagnie_id' value='' select_text='--- not set ---' class='form-control' output='bootstrap']
	</div>

How to directly modify already existing shows in the compagnies list?
1. Create a new Layout, insert a CRED Form cell. Choose the CRED form 'Modifier Spectacles'
2. Edit the View afficher-les-spectacles. In "Loop item in afficher les spectacles" use the Fields and Views button to insert a CRED Edit Post link. Select the Layout from step1.

#614694

Thank you Christian

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