First and most important, I have no coding experience and my knowledge is limited to copy/pasting codes and make small tweaks.
Goal:
Information submitted using a CRED form to generate a custom post title.
Issue:
When using the below code in the functions.php file in my theme, it outputs "{Spotlight} Array by Array"
I need to figure out how to get it to replace the word array with the data submitted in the CRED form.
add_action('cred_save_data', 'build_title', 10, 2); function build_title($post_id, $formdata) { if ($formdata['id']==8930) { $field1=get_post_meta($post_id, 'book-title'); $field2=get_post_meta($post_id, 'author'); $post_title="{Spotlight} $field1 by $field2"; wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title)); } }
If I add ", true" as shown below, the output post title ignores these fields altogether
$field1=get_post_meta($post_id, 'book-title'); $field2=get_post_meta($post_id, 'author');
Could someone please tell me where I have gone wrong and how to resolve this?