Skip Navigation

[Resolved] How to use Types field value in functions.php

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This support ticket is created 9 years, 1 month ago. There's a good chance that you are reading advice that it now obsolete.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.

This topic contains 1 reply, has 1 voice.

Last updated by rusty 9 years, 1 month ago.

Author
Posts
#289297

I am trying to: use the value entered in a CRED form and displayed in the back end in a CPT in an action in functions.php

I visited this URL:

I expected to see:

Instead, I got: Fatal error: Call to undefined function types_render_field()

Users fill out a form on the front end (CRED) and include their email address. The email address is visible in the back end in the CPT. I want to pass that value (the user's email address) to a function in functions.php.

I tried assigning it to a variable

$authorEmail = types_render_field("wpcf-your-email", array("raw"=>"true"));

But when I click "Update", I get the error Fatal error: Call to undefined function types_render_field()

I read somewhere else that frontend.php needs to be included, but I've had no luck getting that to work. How/where do I include it or is there another solution for using types field values in functions.php?

#289322

Figured it out...

The key is to use types_get_field_meta_value instead of types_render_field


// get the post id and assign it to a variable
$post_id = get_the_ID();

//get the value from the field as it appears in the post with the ID from above and assign it to a variable
$fieldval = types_get_field_meta_value( 'your-field', $post_id );

From there you can drop in the $fieldval variable wherever you need it in your function.

Note: 'your-field' is the types name without wpcf- prefix

The forum ‘Types Community Support’ is closed to new topics and replies.

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