I am trying to: Generate post title from CRED submission using custom taxonomies and custom fields.
I visited this URL: https://toolset.com/documentation/programmer-reference/cred-api/#csd
I expected to see: The taxonomy name
Instead, I got: the taxonomy value + name
Hello, having browsed through all previous posts related to autotitle from CRED submission I ended up with this code, knowing that I want to use several custom taxonomies combined with several custom fields (XXXX to be replaced with my form ID):
//* CRED autotitle
add_action('cred_save_data','func_custom_post_title',10,2);
function func_custom_post_title($post_id,$form_data) {
if ($form_data['id']==XXXX) {
$auctiontype = get_the_term_list($post_id, 'listing-type', true);
$auctiondate = get_post_meta($post_id, 'wpcf-auction-ending', true);
$auctiondate = date('d-m-Y',$auctiondate);
$carbrand = get_the_term_list($post_id, 'car-brand', true);
$title= $auctiontype. ': le ' . $auctiondate. ' - ' . $carbrand;
$args = array('ID' => $post_id, 'post_title' => $title);
wp_update_post($args);
}
}
The resulting title looks like this: 1'En attente de confirmation: le 26-05-2017 – 1Porsche 911' (notice the '1' before each custom taxonomy name), whereas of course I'd like to get this: 'En attente de confirmation: le 26-05-2017 – Porsche 911'
For the record, in order to retrieve the custom taxonomies I also tried the following code, but to no avail (nothing showed up):
$auctiontype = wp_get_post_terms($post_id, 'listing-type');
Any help or hint would be most welcome.
Thanks.