[Resolved] Append Title to another Post submitted through cred
This support ticket is created 7 years, 9 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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Instead, I got: Most of the answer. I am trying to specifically target the title of the post thats ID is stored in 'wpcf-g-doc-number'. Below is what I have so far, and if this is outside the scope of support I understand, just thought I'd give it a try. Thanks.
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data)
{
//if form
if ($form_data['id']==299)
{
if (isset($_POST['g-doc-number']))
{
add_post_meta($post_id, 'wpcf-g-doc-number', $_POST['g-doc-number'], true);
}
$my_post = array(
'ID' => $post_id,
'post_title' => 'Enquiry re: '.get_the_title($post_id) //This is where I'd like to get the title of the post with the ID stored in 'wpcf-g-doc-number'
);
// Update the post into the database
wp_update_post( $my_post );
}
}
Thanks Shane for the quick response. I was showing the whole function for clarity, but the first part is already working. The field used is a generic field and the only way I could get it to work was to omit the 'wpcf-'.
As for the rest, I tried combinations of both of the changes you recommended and I'm still getting 'Enquiry re: Auto Draft 8c9f.....' as the title on my new posts. Any other ideas?
The post being created is it suppose to provide a title for another post ?
Meaning get_post_title is getting the title from $post_id .
This means that if the post with the id that stored in the $post_id variable does not have a title then it is going to provide an Auto Draft title for the other post.