Skip Navigation

[Resolved] Linking a child post to parent post from a list

This support ticket is created 2 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 12 replies, has 2 voices.

Last updated by nicolaS-3 2 years, 4 months ago.

Assisted by: Minesh.

Author
Posts
#2407697

Hi
Referring to this:
https://toolset.com/forums/topic/creating-forms-with-a-parent-post-preselected/
I have this:

[cred_field field='@pub-event.parent' class='form-control' output='bootstrap' required='false' default='[wpv-post-id]']

I also tried this:

[cred_field field='@pub-event.parent' class='form-control' output='bootstrap' required='false' ID='[wpv-post-id]']

none of the two connects the new child event post to the parent pub post (relationship is empty). Is it because the calling view is a list and not a single post ?
What can I do to pass the parent post ID to the child from a list ? should I use a URL parameter or is there a better way ?
thanks
Regards
Nicola

#2407743

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

What if you try to use the following shortcode where we apply and set the default value using the value attribute:

value='[wpv-post-id]'

For example:

[cred_field field='@pub-event.parent' class='form-control' output='bootstrap' required='false' value='[wpv-post-id]']

More info:
=> https://toolset.com/documentation/programmer-reference/forms/cred-shortcodes/#cred_field

Does that helps?

#2407777

Hi Minesh,
nope, the event is created but the relationship is empty

#2407781

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I need to check whats going wrong and how you setup the things.

Can you please share problem URL as well as admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2407817

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

I login as admin and when I try to access the problem URL page you shared:
- hidden link

It shows me login form. Do I need to login as frontend user? If yes, could you please share frontend user access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2407857

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Could you please check now.

With the view that displays the pub information where you added the Add Event link:
=> hidden link

I've adjusted the link to add "CREA EVENTO" as given under:

<a href="<em><u>hidden link</u></em>;">CREA EVENTO</a>

Now, we are passing the current post ID as URL param ?parent_pub_id=[wpv-post-id]" and this will automatically populate the parent field and when you submit the new event it will automatically associated with the related pub.

I've created the folloing test event and I can confirm the event is linked to related parent (ID) passed as URL param.
=> hidden link

Could you please confirm it works at your end as well.

#2407881

Hi
it works this way, thanks. Just wondering what happens if some stupid decides to delete the pub ID or - even worst - change it to another one that actually exists !!! (the event would be linked to another pub !!). How can I control this ?

#2407897

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Are you working on the site, as I get site not reachable message? if no, I will require FTP access details as it seems the custom shortcode I've added could be the culprit.

Could you please share FTP access details.

I have set the next reply to private which means only you and I have access to it.

#2407913

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

There must be issue with your server as I'm getting "The connection has timed out" on admin section as well. Could you please check and get back to me.

#2407945

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Ok it seems it must be the Wordfence plugin that should blocked me. Its back to work when I switch to different network.

So, to validate such way, you should use encode and decode method for query string value and then pass it as URL param.
- https://stackoverflow.com/questions/28316457/encrypt-php-query-string-value-in-url

you need to build custom shortcode that should return the encode and decode value based on the URL param.

That is the best way I can think of.

#2407999

HI,
thanks for your indications, but this solution goes beyond my abilities. To avoid this I tried to change the user experience: let the user select the pub first and then the single pub page opens: here I placed the CREATE EVENT button. I then changed the [encode_param] back to value=[wpv-post-id] (I also tried default=[wpv-post-id]). According to this doc
https://toolset.com/documentation/legacy-features/views-plugin/selecting-parent-posts-using-forms-create-child-items/
if the parent post is preselected the form "knows" which is the parent post, but it doesn't work either ! the doc doesn't explain the button link syntax, so I just call the page....any clue ? thanks

#2408279

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

You will have to add the shortcode to display child form link and you can do that by adding the "Fields and Text" block and then from the forms icon you should click on the button "Create child post link".

[cred_child_link_form form='7097' text='CREA Evento' target='_self']

I've added to your content template here:
- hidden link

And you will see that: hidden link with another link is displayed "CREA Evento".

If you do not wish to add that way, you should adjust the button link as follows which I did already for your button block:

<em><u>hidden link</u></em>;

You need to decide what you want to use.

#2408399

My issue is resolved now. Thank you!