Skip Navigation

[Resolved] Title of post from the select field (cred save data)

This thread is resolved. Here is a description of the problem and solution.

Problem:

Get custom select field option displayed text instead of the value.
Is it possible?

Solution:

You can try the Types API function types_render_field(), for example:

$ploshhad = types_render_field("ploshhad", array( 'post_id' => $post_id));

Relevant Documentation:

https://toolset.com/documentation/customizing-sites-using-php/functions/

This support ticket is created 6 years, 7 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.

Our next available supporter will start replying to tickets in about 1.56 hours from now. 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)

This topic contains 2 replies, has 2 voices.

Last updated by Max 6 years, 7 months ago.

Assisted by: Luo Yang.

Author
Posts
#771648

Max

I have a function that dynamically updates the title of the CPT when saving with Cred, which is great.

//Update summa-ploshhadi field when selecting ploshad field
function save_multiple_fields_func($post_id, $form_data){
    if (in_array($form_data['id'], array(18, 45))) {
        $ploshhad = get_post_meta($post_id, 'wpcf-ploshhad', true);
        update_post_meta($post_id, 'wpcf-summa-ploshhadi', $ploshhad);
        // here you can update other custom fields value
    }
}
 
add_action('cred_save_data', 'save_multiple_fields_func',10,2);

I also have a custom select field, created with Types (wpcf-ploshhad).

I'm trying to find out if the following is possible.
I want the line $ ploshhad = get_post_meta ($ post_id, 'wpcf-ploshhad', true); returned the displayed text instead of the value. Is it possible?

#775044

Hello,

You can try the Types API function types_render_field(), for example:

$ploshhad = types_render_field("ploshhad", array( 'post_id' => $post_id));

More help:
https://toolset.com/documentation/customizing-sites-using-php/functions/

#775636

Max

Thank you, Luo, now it works as I want