Sauter la navigation

[Fermé] Edit form only in frontend – continued

This support ticket is created Il y a 4 années et 1 mois. 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)

Auteur
Publications
#1867547

MAI:
Hi there,

I was told to open a new ticket with the "part 2" of my problem.
I want the host of my camps to be able to edit their camps in front end. At no point they can access the backend. The problem is that we have 1 WooCommerce product linked to every camp as it has to be possible to buy a ticket for the camp online. So right now you can only edit the camp info and not the product info, since it is not possible to edit more than 1 form.
I had help from Jamal who wrote this:
_______
SHANE:
From what I gathered so far, Products are linked to Camps in a One-to-many relationship. Please correct me if I am wrong, you want to allow the camp authors to create the linked products or edit them from the frontend, right?
Currently, a Toolset Form can only create or edit ONE post. So, you won't be able to update the linked products' information from the same Camp form. You will need to create separate forms and put them in separate content templates. For example, after editing a camp redirect the user to the camp single page, and conditionally display the form(s) to edit the linked products using a view and a form inside of it.
Regarding the sidebar, it seems that the "The7" theme allows you to enable/disable the sidebar only for Pages and Posts, from the configuration page (Theme Options->Sidebar). I'll suggest contacting the theme's support and asking how can we disable the sidebar for a custom post type(Camps).
However, for support rules, we are able to handle only one issue at a time. This helps us to bring you a better service and also helps other users to find all the information here exposed. For that reason, I have to kindly ask you to open a new thread if you need further assistance with creating/editing products that are linked to a camp. In the meantime, check the following articles on how to create a product from the frontend, and how to create a child product from the parent product page.

Can you please help? thanks.

_____________
SHANE:
Hi Mai,
So that i'm up to speed on this, you are currently displaying your products on the camp page correct?
It is true that you won't be able to edit the Products on the camp edit form, however you can add a link to edit each individual camp and when clicked it will take you to the individual form responsible for editing the camp.
If you'll like to implement this please let me know and we can go from there.
Thanks,
Shane
______________
MAI:
Hi shane,
I am so sorry for the late reply. I got hurt and had to have eye surgery so I was out for a few weeks. My topic is closed now, so that is why I am creating a new one like this.
For me it is okay that you edit “1 form at a time” so that you first edit the camp info, like you are able to do now, and then press “next” to edit the price, number of available spots etc.
Can you please let me know what you need to get started with this? 

Thank you.

#1868337

Hello, it sounds like you have a Camp CPT and a Product CPT (from WooCommerce). Camps are related to Products in a one-to-many relationship, where Camp is the parent and Product is the child.

You want to allow Users to edit Camps and their related Products on the front-end of the site. As other supporters have explained, it is only possible to edit a single post using a single Form. So you could create an Edit Camp Form and insert it in an unassigned Content Template. Then in the Camp Form template, you can insert an Edit Post Form Link and select the template that contains the Edit Camp Form. This link will redirect the User to the Edit Post Form you inserted in the Content Template.

To edit each Product, you must create an Edit Product Form and place it in an unassigned Content Template. Note that it is only possible to edit Simple Products in Forms. Variable Products and other product types are not supported at this time. Once you have inserted the Form in a Content Template, you must create a View of Products to display inside the Camp Content Template. If you create the View in the Block Editor, you can configure the Content Selection to display Products related to the post where the View is shown. If you create the View in the legacy Views editor, you must add a post relationship Query Filter configured to only display Products related to the post where this View is shown.

In the Loop of that View, you can insert a link to the Product, or the Product title, and an Edit Post Form Link. In the settings for the Edit Post Form Link, choose the template that includes the Edit Product Form. Then insert this View of Products inside the Content Template for the Camps post type. This will create a list of related Products, and include a link to edit each Product in a separate Form.

Let me know if you have questions about this.

#1870257

Hi christian,

Shane was actually the one making the changes because i could not get it to work when i tried. So i am not sure how to implement what you suggest, since i dont know where to do it.

Is it possible to make a guide or anything? I tried following your guide on how to make an edit function in the frontend but as i told you i could not get it to work so i had Shane help me. But what he exactly did i am not sure of.

Thanks

#1870505

I can log into wp-admin and see what you have created so far, and offer some more guidance based on your current setup. Please provide login credentials in the private reply fields here so I can access wp-admin. I'll take a look at what you have in place, and offer some suggestions for next steps.

#1870563
Screen Shot 2020-12-09 at 10.40.31 AM.png
Screen Shot 2020-12-09 at 10.39.40 AM.png

Okay I see you have an unassigned Content Template here that contains the Edit Product Form: lien caché

I see you have a Content Template assigned to the Camp post type here:
lien caché
I see this Content Template contains a View of related Product posts. Now inside the Loop block of this View of Product posts, you can insert an Edit Post Link using a Fields and Text block. Select the Loop block and add a new Fields and Text block, then click the Forms icon above the editor area to insert an Edit Post Link (see the screenshots here).

#1870605

hi Christian,

I am not sure i am following.

Shane already made it possible to edit the camp - or that is: Some of the camp. Since the camp info and camp product info is 2 different posts, I need kind of a "next" button that links to the product camp info after youre done editing the basic camp info.

If you take a look here: lien caché
You will see the edit button called "Rediger camp". If you press this you'll see that you can edit some of the info, and this is where i need a link or something to the next form with informations (price, quantity etc) for the specific camp.

I tried following your above message but when i press the link to the camp post type i get this: Something went wrong while fetching the dynamic content from the selected source, with message: "Sorry, you are not allowed to do that.".

And also i am not sure where to insert the text box etc. Can you help?

#1870635

If you press this you'll see that you can edit some of the info, and this is where i need a link or something to the next form with informations (price, quantity etc) for the specific camp.
Okay so you want to display the Edit Product links in the same page that contains the Edit Camp Form, e.g. lien caché.

You do not want to display the links to edit each Product in the original Camp post, is that correct?

If so, you need a separate View of Products in the Content Template that contains the Edit Camp Form, here: lien caché
Inside the loop of this View, you must include a Fields and Text block and insert an Edit Post Link like I was describing before. I've set up a quick example View for you in the Content Template, so you can see how it would work. You can find the View in the Content Template editor, below the Edit Camp Form block.

I added a Single Field that displays the related Product link, as well as the Edit Post Link with the text "Edit Product". If you want to use some other text, delete the Fields and Text block and create a new one. Then use the Forms icon to insert a new Edit Post Link, and set the desired text in the popup.

To display the Edit Product Form, I also created the unassigned Content Template that includes an Edit Product Form block:
lien caché

#1870715

Hi Christian,

I just tried editing a camp and now it doesnt work. I will try to explain what i want again:

1) The host create a camp
2) The host access his profile and is able to see the camps he created
3) The host see that there is a wrong address and a wrong price entered on the camp
4) On the camp post page (the page that the world and the host sees with the camp) the host press "Edit camp".
5) The host now (in the frontend) enters a form where he can edit the address and the price
6) The host press "submit" and now the changes are saved.
7) The hosts enters his camp again and now the new info is public.

This is what i need. Then as i told you Shane fixed it but had some trouble with the product part and said that he needed to ad a link since there are 2 different post forms to fill out when you create a camp (1 for the basic info and 1 for the woocommerce info).

#1870747
Screen Shot 2020-12-09 at 1.14.36 PM.png

It seems to be saving the updates correctly, but redirecting to a different location upon submission. See the screenshot here - the Form is set to redirect to a custom Page called "Host - edit your product". I'm not sure if you set that up, or if Shane set that up. This causes the Form to redirect to another page after the Form is submitted. Earlier, I asked -
"Okay so you want to display the Edit Product links in the same page that contains the Edit Camp Form, e.g. lien caché."

Now I need you to clarify, because these are two different things. Either you can redirect to a separate page, or you can reload the same page when the Form is submitted. Which do you prefer?

#1870759

Hi Christian,

Oh I see - I have not set anything up so the redirect link should just go back to the camp when the changes are saved. Maybe shane tried to redirect to the second form that edits the price etc.

When the changes are saved (new price, new address, whatever) i would like it to go back to the camp that you just worked on. 🙂

#1870773

In this case, the correct setting should be "Display the post". I have made that change for you, and the Form redirects to the original Camp post after submission. Now, do you want to display the Edit Product Links in the Edit Camp Form page, or in the original Camp post, or in both locations?

#1870779

Thank you!

In both places i think. So it will be as easy as possible.

#1870781

Under the "submit" button right now there is a link with the camps title. I think it leads to the woocommerce part but nothing is there. Do you know what it is?

#1870803

Yes, it is exactly what you mentioned. The related Product View is set up to display a link to the related Product post page, and a link to the Edit Product Form, for each related product. I added it there for testing purposes, to confirm the list of related Products is accurate. What would you like to display instead?

#1870913

Hi Christian,

I am not sure i understand. I am sorry.
I just need to be able to edit the price and quantity etc as well, and that i can not do right now. I can only edit the basic information right now and not the woocommerce product info. Basically i do not have a preference on how it is being set up - i just need to be able to edit both basic info and then the woocommerce product info.

Once all the info has been changed and saved i should return to the camp I just edited.

Thanks.

Le sujet ‘[Fermé] Edit form only in frontend – continued’ est fermé à de nouvelles réponses.