[Resuelto] Automatically set post parent in post form from URL parameter
Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.
Problem:
Automatically set post parent with Toolset CRED form using new post relationship
Solution:
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:
add_action('cred_save_data','func_custom_post_title',15,2);
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);
}
}
This support ticket is created hace 6 años, 6 meses. 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.
Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.
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.
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.
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.
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.
Here is the steps I follow:
=> I load this URL: enlace oculto
=> 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. enlace oculto
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: enlace oculto
=> 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.
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