Relationship to current post id
-
Hello Konrad,
I read the topic of the attached link because I’m trying to do the same as the user. However, I think you may have misunderstood his question. (…or I may have.)
I have a Customer CPT. The customer creates their account through a previously filled form. Once the account is created, the customer can access the front end of their account where they can complete an order form.
The Order is a separate CPT (each performs functions that are sometimes unrelated). The Customer and the Order are joined by a bidirectional relationship field.
When a customer is in their account and when they fill the order form, a new order is created in the Order post type.
I need to assign the Order with the Customer. I had the same idea as kamyarhu (the user who posted the original question) I created a hidden field with the same name as the bidirectional field and during post save, the field saves the current post id in the new Order post in the identically named relationship field. In my theme functions I passed the current post id to the form field and it works – but for me, only on the Order side. The relationship field isn’t reciprocated on the Customer side – even though it’s a bidirectional field.
I read your answer and tried your suggestion of creating a relationship field hidden on the front end. My issue is that by the time the new post is created, I no longer have the customer post id where the order form was created, so I don’t know how to update the bidirectional field.
It seems like it would be fairly common to associate a new post with the post where the form resides… Do you have any suggestions?
The page I need help with: [log in to see the link]
The topic ‘Relationship to current post id’ is closed to new replies.