Skip Navigation

[Resuelto] How to update child post value from parent post

Este hilo está resuelto. Aquí tiene una descripción del problema y la solución.

Problem:
How to update child post value from parent post

Solution:
You can use Toolset Forms (CRED) hook "cred_save_data" to set child post value.

You can find the proposed solution, in this case, with the following reply:
https://toolset.com/forums/topic/continuation-from-previous-ticket/#post-1122659

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

This support ticket is created hace 6 años, 1 mes. 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.

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)

Etiquetado: 

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por geoffD hace 6 años, 1 mes.

Asistido por: Minesh.

Autor
Mensajes
#1121712
Screen Shot 2018-10-05 at 20.36.55.png

Hi Minesh

I've opened a new ticket as the last one I closed, however there is one last thing I need to do...

I need the custom field 'Adopted' of the CHILD whose child post ID you pass in the URL to become 'Yes' when the new PARENT is created.

I'm happy for you to use the same login details as before...

I really appreciate your help...I'm also learning at the same time!

I have added a screenshot from your notes from the previous post in case you don't remember:

Many thanks

Geoff

#1122617

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Yes - I understand the code but when you mean by you need the custom field of the child post.

Do you mean that you want to save "Adopted" field value to parent post or child post?
If it's child post - its not saved?

#1122653

Hi Minesh

Hope you've had a great weekend!

Yes that's what I mean..As the spy being saved at the time is the new PARENT I also need the CHILD custom field 'Adopted' to be filled and saved with 'Yes'... At the moment we just pass the CHILD ID..

Many thanks as always

Geoff

#1122659

Minesh
Supporter

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Well - I've updated the code in functions.php file as given under.

add_action('cred_save_data','func_update_parent_field',10,2);
function func_update_parent_field($post_id,$form_data) {    
		if ($form_data['id']==2613) {       
				wp_update_post(array('ID' => $_REQUEST['child_post_id'],         'post_parent' => $post_id    ));    
				update_post_meta($_REQUEST['child_post_id'],'wpcf-adopted',$_POST['wpcf-adopted']);
		}
}

Could you please confirm it works as expected.

#1122760

My issue is resolved now. Thank you Minesh!!!