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?
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