I know the extince of the default title Filter but i am stuck how i can get 2 submitted fields in the title?
there are several ways to achieve this, either change the saved post with the action fired at the end of the mapping process (action #16 in the helper codes, see screenshot #8),
add_action('cf7_2_post_form_submitted_to_formulaire-rtl', 'new_formulaire_rtl_mapped',10,4);
/**
* Function to take further action once form has been submitted and saved as a post. Note this action is only fired for submission which has been submitted as opposed to saved as drafts.
* @param string $post_id new post ID to which submission was saved.
* @param array $cf7_form_data complete set of data submitted in the form as an array of field-name=>value pairs.
* @param string $cf7form_key unique key to identify your form.
* @param array $submitted_files array of files submitted in the form, if any file fields are present.
*/
function new_formulaire_rtl_mapped($post_id, $cf7_form_data, $cf7form_key, $submitted_files){
//do something.
}
or using a custom filter on the title field (select the filter option from the dropdown menu in the mapping admin page):
add_filter('cf7_2_post_filter-my-form-title','filter_my_form_title',10,3);
function filter_formulaire_rtl_title($value, $post_id, $form_data){
//$value is the post field value to return, by default it is empty. If you are filtering a taxonomy you can return either slug/id/array. in case of ids make sure to cast them integers.(see https://codex.ww.wp.xz.cn/Function_Reference/wp_set_object_terms for more information.)
//$post_id is the ID of the post to which the form values are being mapped to
// $form_data is the submitted form data as an array of field-name=>value pairs
return $value;
}
In both cases the submitted values ($cf7_form_data) from your form fields are passed to the callback function, so you can retrieve the fields you need to create your title.
@aurovrata thanks that will help.
sure, please note that all these helper codes are available in the admin mapping page itself when you click on the filter/action links.