Skip Navigation

[Résolu] Title of post from the select field (cred save data)

Ce fil est résolu. Voici une description du problème et la solution proposée.

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 Il y a 6 années et 7 mois. 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.

Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.

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)

Ce sujet contient 2 réponses, a 2 voix.

Dernière mise à jour par Max Il y a 6 années et 7 mois.

Assisté par: Luo Yang.

Auteur
Publications
#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