I would like to use cred_before_save_data to concatenate some text (set by value attribute in CRED) and the term names from selected from two taxonomies and make the result the post title.
Portion of my CRED form:
[code]
[cred_field field='post_title' post='event' value='Kamloops vs ' urlparam='' class='form-control' readonly='true' output='bootstrap']
[cred_field field='team' display='checkbox' display='select' single_select='true' output='bootstrap']
[cred_field field='event-category' display='select' single_select='true' output='bootstrap']
[/code]
I understand that the php would look something like:
[code]
add_action('cred_save_data', 'build_title', 10, 2);
function build_title($post_id, $formdata)
{
// if a specific form
if ($form_data['id']==64)
{
$field1=get_post_meta($post_id, 'wpv-taxonomy1name');
$field2=get_post_meta($post_id, 'wpv-taxonomy2name');
}
$post_title="$field1 $field2";
wp_update_post(array('ID'=>$post_id, 'post_title'=>$post_title));
}
[/code]
But I'm not sure how to put it all together. What the variable names of the selected taxonomy terms would be.
with get_post_meta() you get... post meta.
https://developer.wordpress.org/reference/functions/get_post_meta/
To get terms, you need another function.
wp_get_post_terms() will help you to get all terms of a certain taxonomy added to a certain Post ID.
https://codex.wordpress.org/Function_Reference/wp_get_post_terms
get_the_terms is similar:
https://developer.wordpress.org/reference/functions/get_the_terms/
With that, you should be able to proceed.
I feel like someone just handed me a bucket of parts and called it a toaster.
I'm sorry, Darryl, we do not provide custom code in the forum.
https://toolset.com/toolset-support-policy/
What we provide is information how you can do it, we can look at code and test or reccomend better approaches, and so on.
But we cannot deliver ready to use code.
With the above elaborated function you can get the terms.
With this, you can then use wp_update_post and construct the Post Title with the data you got previously.
As example, if you want to update a Post Title with a Custom Field you would use this code:
https://pastebin.com/2BTbVbcs
If you want to add more values, you need to get them first (with above elaborated Function) and then concatenate them (.=) with PHP to create a new Title.
You can also use the $_POST.
This holds all information of the Form itself, before you submit it.
You can access $_POST data by using $_POST['form-field-slug'].
That can then be used to populate a PHP $variable, wich later you can use in the wp_update_post() function.