Skip Navigation

[Resuelto] I want to save the form record with a custom field. Toolset form

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

Problem:

I want to save the record of a form entry with a custom form field, how can I make it save with the name of a form field?

Solution:

You can try Forms action hook "cred_save_data", for example:

https://toolset.com/forums/topic/i-want-to-save-the-form-record-with-a-custom-field-toolset-form/#post-1659797

Relevant Documentation:

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

100% of people find this useful.

This support ticket is created hace 3 años, 10 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

Etiquetado: ,

This topic contains 2 respuestas, has 2 mensajes.

Last updated by DavidZ1525 hace 3 años, 10 meses.

Assisted by: Luo Yang.

Autor
Mensajes
#1658999

Tell us what you are trying to do?
I want to save the record of a form entry with a custom form field. At this time it is saved under this name. CRED Auto Draft e1be45a8402292fdd114da8d742ea44a

How can I make it save with the name of a form field?

Is there any documentation that you are following?
https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/

Is there a similar example that we can see?
No
What is the link to your site?
hidden link

#1659797

Hello,

You can try Forms action hook "cred_save_data", for example:

add_action('cred_save_data', 'build_post_title', 10, 2);
function build_post_title($post_id, $form_data) {
	if ($form_data['id']==123) {
		$field1_value = get_post_meta($post_id, 'wpcf-field1_slug', true);
		$field2_value = get_post_meta($post_id, 'wpcf-field2_slug', true);
		  
		$post_title= $field1_value . '-' . $field2_value;
		$slug = sanitize_title($post_title);
		wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title,'post_name' => $slug));
	}
}

Please replace 123 with your post form ID, replace "field1_slug" and "field2_slug" with your custom field slugs.

More help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://developer.wordpress.org/reference/functions/wp_update_post/

#1660353

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.