As CRED API hooks and so this shortcode/callback function must be triggered somewhere in the form before or after the submit button?
The hooks are triggered automatically by the CRED plugin after the submit button is pressed. Nothing else is required.
where to put shortcode actions into forms and layouts regarding CRED
No additional shortcodes are required. The callback PHP functions you created will be automatically triggered during the CRED form submission process.
add_action('cred_save_data', 'my_save_data_action',10,2);
The code above tells WordPress to call the "my_save_data_action" function any time a CRED form is submitted. If you want to call this function only when a specific form is submitted, you must apply a conditional in your code or use the form ID in the hook name. I will show examples of each approach below.
Conditional approach:
add_action('cred_save_data', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data) {
// if the form being submitted has ID "12345"
if ($form_data['id'] == 12345)
{
// add your code here, it will be executed only when form "12345" is submitted
}
}
This approach is more flexible but requires more code. You can apply the same callback function to multiple forms by modifying the conditional.
Form ID in hook name approach:
add_action('cred_save_data_12345', 'my_save_data_action',10,2);
function my_save_data_action($post_id, $form_data) {
// add your code here, it will be executed only when form "12345" is submitted
}
This approach is less flexible, but requires less code. There can be only one my_save_data_action function, and it can only be applied to one form - 12345.
Let me know if I can help clarify this further.