Skip Navigation

[Resolved] automatically input single field line from checkbox

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
- 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)

This topic contains 2 replies, has 2 voices.

Last updated by simchaH 2 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#2218055

Hi,

I have 2 CPT's. In one of them I have two single fields for users to input first and last name. I have a third field, a multi-checkbox where a user can select from a few options. I would like to know if it is possible to have it that when I select one of the checkboxes and save the new entry, the two single fields get saved to the second separate CPT, either in 1 single line field as the full name of the person, or the exact same way it was saved in the original CPT, as two separate single line fields.

In short, I am wondering if it is possible to simple automatically duplicate field entries and add them to another CPT based on whether a checkbox is selected or not. This will create a redundancy as I will have the first and last name of a person saved in both CPT's, but I am okay with that.

Thank You!

#2218143

Hello,

One post forms can handle only one post at the same time, it can not handle tow posts in different post types.

You might need to consider custom codes, for example:
1) After user submit the form, use action hook cred_save_data to trigger a PHP function
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data

2) In this PHP function:
a) get the custom checkboxes field value:
https://toolset.com/documentation/customizing-sites-using-php/functions/
b) Check the checkboxes field value, then create a new post in another post type:
https://developer.wordpress.org/reference/functions/wp_insert_post/
And setup the custom fields values:
https://developer.wordpress.org/reference/functions/update_post_meta/

For your reference.

#2218951

Thank you for this info, I will check it out.

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