Hello Yoshihiko,
Here are the answers to your questions.
1. Use the "cred_save_data" hook. It runs right after the form saves the post. You can limit it to one form with "cred_save_data_form_" followed by the form slug.
2. The hook receives the new post ID as its first parameter.
3. Yes. The post is already saved when the hook runs, so you can call update_post_meta() there.
4. In the form settings, set "After visitors submit this form" to "Go to a page..." and pick your "Business System Self-Diagnosis Report" page. Then use the "cred_success_redirect" filter to add the post ID to the URL.
Here is an example for your form. Add it to your theme's functions.php or in Toolset > Settings > Custom Code:
add_action( 'cred_save_data_form_business-system-self-diagnosis', function ( $post_id, $form_data ) {
update_post_meta( $post_id, 'your-meta-key', 'your value' );
}, 10, 2 );
add_filter( 'cred_success_redirect_form_business-system-self-diagnosis', function ( $url, $post_id, $form_data ) {
return add_query_arg( 'report_id', $post_id, $url );
}, 10, 3 );
On the report page you can read the ID with [wpv-search-term param="report_id"], or with $_GET['report_id'] in PHP.
You can find all the Forms hooks here:
https://toolset.com/documentation/programmer-reference/cred-api/
The custom code suggested above is not part of our official support policy. We will not be able to maintain or guarantee that it will work. It is an attempt to help you understand what should be done for scenarios where the built-in Toolset features are not there to handle your request.
Thanks.