Skip Navigation

[Resuelto] Submit Once and Save in Two Fields

This support ticket is created hace 6 años, 11 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
- 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)

This topic contains 4 respuestas, has 2 mensajes.

Last updated by Sean hace 6 años, 11 meses.

Assisted by: Minesh.

Autor
Mensajes
#522753

Due to a limitation with Views, I need a user submitted field to be saved to two different custom fields at the same time.
It's a date field, to be more specific. I have a "newdatefield" as part of the form. But I want that same information to also be saved to "olddatefield" when the user submits. There a way to do this using the "value" option?

#522870

Minesh
Supporter

Languages: Inglés (English )

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

Hello. Thank you for contacting the Toolset support.

Could you please clarify for which post type you want to save your custom field and whats your custom field name and is that created using Types?

Also - you want to save custom field value to another field while add/edit post at backend (admin) section?

#523153

The post type is: events
Everything was created with Types.
The main custom field: starting-daytime-10
The one I want to be an exact copy of the one above: start-date-raw
Both are date fields.

I am using CRED to create these post types. So when the user submits the form, it places the exact same date information into those two fields without them having to select the date twice.

#523311

Minesh
Supporter

Languages: Inglés (English )

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

Ok - as you are using CRED form you can use CRED hook cred_save_data

More info:
=> https://toolset.com/documentation/programmer-reference/cred-api/#csd

For example:

add_action('cred_save_data','func_custom_post_title',10,2);
function func_custom_post_title($post_id,$form_data) {
 
  if ($form_data['id']==9999) {

    $org_date_value = get_post_meta($post_id, 'wpcf-starting-daytime-10', true);
   update_post_meta($post_id, 'wpcf-start-date-raw', $org_date_value );

  }
 
}

Where:
- Please replace 9999 with your original CRED form ID

I hope above solution will help you to resolve your issue.

#523525

Awesome, that worked. Thanks.

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