Hello Ravendays,
I’m glad to hear that my plugin help your organization 🙂
I’m currently writing documentation on the website in order to explain all features. Meanwhile, here are some explanations:
In ACF Extended Dynamic Forms, you have multiple levels of control for your form. Let’s say you have the following configuration:
Form name: my_form
Actions:
– Email
– Custom action: my_action
– Create post
The actions are triggered following the order you’ve set in the form administration. In this example the custom action my_action will be triggered at the second position. If you want to execute an action here, you will have to use:
add_action('acfe/form/submit/action/my_action', 'my_action', 10, 2);
function my_action($form, $post_id){
// get_field('my_text_field');
// Do something in my_action
}
This action will be executed after the Email action, and before the Create post. Now, let’s say you have 2 forms, and in both forms you have the same custom action called my_action. If you want to target my_action in a specific form, you can use the following hook:
add_action('acfe/form/submit/action/my_action/name=my_form', 'my_action', 10, 2); (note the /name=my_form at the end).
Dynamic Forms are packaged with working actions: Email, Post, Term & User. Those actions also have action name:
Email – action name: email
Post – action name: post
Term – action name: term
User – action name: user
Those action names are reserved, because they are used by the native form actions. That’s why you can’t use them as “Custom action name”.
Let’s say you want to trigger an action after sending an email in the form my_form, you can use the following hook:
add_action('acfe/form/submit/action/email/name=my_form', 'my_email_action', 10, 2);
function my_email_action($form, $post_id){
// Do something after sending an email in my_form
}
Now let’s say you want to do something at the end of your form submission, and you don’t want to target a specific action, you can use the following hook:
add_action('acfe/form/submit/name=my_form', 'my_form_action', 10, 2);
function my_form_action($form, $post_id){
// Do something after form submission & after all actions
}
Hope it’s clear 🙂
Have a nice day!
Regards.