Skip Navigation

[Resolved] use custom field value to modify another field

This support ticket is created 4 years, 8 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
- 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 3 replies, has 2 voices.

Last updated by Minesh 4 years, 8 months ago.

Assisted by: Minesh.

Author
Posts
#1821495

Since there is no field that allows meto enter time I am using separate fields for days, hours, minutes and seconds but in order to be able to sort the results in View I need to convert them into "timestamp". Using MY CUSTOM FUNCTIONS plug-in by SPACE X-CHIMP I added following function to form:

add_action('cred_save_data_106', 'save_data_for_form_with_id_106',10,2);
function save_data_for_form_with_id_106($post_id, $form_data)
{
if ($form_data['id']==106) {
echo "I am here and MM equals ", $_POST['mm'];
if(isset($_POST['mm'])){
$time = $_POST['ss'] + $POST['mm'] * 60;
}
if(isset($_POST['hh'])){
$time = $time + $POST['hh'] * 3600;
}
if(isset($_POST['dd'])){
$time = $time + $POST['dd'] * 86400;
}
update_post_meta($post_id, 'czas-wyliczony-dla-wyniku', $time);
}
}

And... nothing happens to 'czas-wyliczony-dla-wyniku' field... what am I missing here?

regards

#1822181

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

I would like to know how you created the following "czas-wyliczony-dla-wyniku" field - using Types plugin or it's a third party plugin field?

#1822313

All the fields above have been created using Toolset.

#1822319

Minesh
Supporter

Languages: English (English )

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

if the field "czas-wyliczony-dla-wyniku" is created using Types:

Then can you please try to replace the following line of code:

update_post_meta($post_id, 'czas-wyliczony-dla-wyniku', $time);

With:

update_post_meta($post_id, 'wpcf-czas-wyliczony-dla-wyniku', $time);

As Types fields are prefixed with the wpcf-{your-field-name}. So if you created the custom field abc it will be stored within the database as postmeta key: wpcf-abc.

Can you please try above and try to resolve your issue.