Skip Navigation

[Resolved] Automatically set post parent in post form from URL parameter

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

Automatically set post parent with Toolset CRED form using new post relationship

You can use new post relationship API function 'toolset_connect_posts' in order to connect two posts in relationship of parent and child in conjunction with the use of cred_save_data hook.

For example:

function func_custom_post_title($post_id,$form_data) {
    if ($form_data['id']==243) {
        toolset_connect_posts('boat-safety-check',$_POST['@boat-safety-check_parent'], $post_id);

You can find proposed solution, in this case, with the following reply:

Relevant Documentation:

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.

This topic contains 26 replies, has 3 voices.

Last updated by Brad Tipper 3 years, 3 months ago.

Assigned support staff: Minesh.


I'm setting up a post form for a post type "Safety Checks" that is set with a post relationship as a child of a post type "Vehicles"

I have the id of the vehicle set in the URL ?vehicle_id=60

My question is this: how can I pull that ID into this part of the post form:

<div class="form-group">
<label>Safety Checks</label>
[cred_field field='@safety-check.parent' select_text='--- not set ---' class='form-control' output='bootstrap']

Rather than having a select drop-down, I want it to be automatically set based on that URL parameter?


You don't need to.

If you already have a Page or Post where you can dynamically append the URL parameter, all you need to do is insert the Form on that page.

Let's say you have 2 Post Types, child and parent
You create a Form to add new Child posts.
You add this form to a Page, where you dynamically pass the URL parameter (?parent_toolset-parent_id=15)
When you visit that page, the Form will already have the Parent Selector set to the parent post with ID 15.

Toolset Forms Parent Selector basically already listens automatically to the URL parameter you mention, there is no need to pass it again to the ShortCode.

You can entirely hide that Field, with some HTML, and pass the parent just with the URL parameter.


OK, so i've set up a content template for the vehicle, and in that content template is a view that lists all "safety checks" that are children of the current vehicle, as well as a cred form to add a new safety check.

There's a dropdown selector (I just autogenerated the form) that lists out the possible vehicles. But, it isn't pre-selected with the current vehicle, nor when you set the vehicle does it save the relationship? Any idea on what might be going on there? I can provide a login if needed- just recently set up a dev install for the site.



Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

Well - Yes, could you please share problem URL and access details so I can check whats going wrong there.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) 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 would additionally need your permission to de- and re-activate Plugins and the Theme, and to change configurations on the site. This is also a reason the backup is really important. If you agree to this, please use the form fields I have enabled below to provide temporary access details (wp-admin and FTP).

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



Languages: English (English )

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

Well - I could not able to login, When I try to login, it again shows authorization popup and page get stuck. Could yo please make simpler login to I can access the backend.


Ah ok, have removed now. Should be fine



Languages: English (English )

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

Well - still I'm facing same issue, login page is loaded successfully but once I enter user/pass and click on submit button the authorization popup shown and I cant able to login.

Could you please fix this issue and send me working wp-admin access details.


Can you try incognito? It is all working perfectly fine at my end....


Or at least send me a screenshot of what you mean?



Languages: English (English )

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

I tried incognito window - does not help.

Here is the steps I follow:
=> I load this URL: hidden link
=> enter username and password and when I click on "Login" button
=> It throws authorization popup - and when I enter the details you shared with username "flux" and password its not working - its just not let me allow to login to wp-admin.


You're using the username "brad", right? There is no longer any kind of protection on the site- i've tried it on three different machines here, different browsers- all work perfectly fine.

Can you try a different browser? A different machine? Has to be some kind of caching issue at your end since everything else loads it fine. hidden link



Languages: English (English )

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


Yes - I use "brad" user name to login to wp-admin and "flux" username to login to authorization popup.
Well - I checked with my another college and he also experience the same problem.

As you can see with the attached image - first page loads fine with login form URL: hidden link
=> I enter username and password and when as soon as I click on "Login" button
=> It throws authorization popup (as you can see with attached image) - and when I enter the details you shared with username "flux" and password its not working - its just not let me allow to login to wp-admin.


Try user "u" and password "2" for that popup. Looks like my hosting adds its own brute force protection for some reason.



Languages: English (English )

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

Ok - Now I'm able to get in and login. Thank you.

You said:
I have the id of the vehicle set in the URL ?vehicle_id=60
==> I do not see the URL param vehicle_id in URL - could you please send me direct link where I can see this ID.


That was the old setup- the next post from support said I don't need to do that. If you take a look through my next 2 posts #901976 and #902007 youll se that the form to create the child post is nested in the parent vehicle template. It populates the auto-generated dropdown correctly, but there are 2 problems:
1- it isn't pre-set with the current parent vehicle
2- even if you manually select the parent vehicle, it isn't saved/linked