• Resolved crazypatx

    (@crazypatx)


    Is there a best practice on how to call wpforms actions to define customized functions?
    I am using “wpforms_display_submit_after” and “wpforms_process_before” for now.

    I have seen examples of people using the actions like that and in the customized function they check which form ID was called via a couple of IF statements to trigger form specific activities.

    But I have also seen examples which add the formID at the end of the action, e.g.
    wpforms_display_submit_after_23
    wpforms_display_submit_after_12
    wpforms_process_before_23
    wpforms_process_before_12

    What is your recommendation / best practice on how to call actions?

    • This topic was modified 1 year, 9 months ago by crazypatx.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Hey @crazypatx – Thanks for reaching out!

    If you look at our documentation here, I’d suggest you use the action name without the form ID. For example, instead of using, you should use wpforms_display_submit_after. This will ensure that your custom function is called for all forms, regardless of their ID.

    If you need to target a specific form, you can do so by checking the form ID in your custom function. For example, the following code will only run for form ID 23:

    add_action( 'wpforms_display_submit_after', function( $form_id ) {
      if ( 23 == $form_id ) {
        // Write your code for Form ID 23
      }
    } );

    I hope that helps, if you have any questions, please feel free to reachout.

    Kindly,

    Hey @crazypatx – We haven’t heard back from you in a few days, so I’m going to go ahead and close this thread for now. But if you’d like us to assist further, please feel welcome to continue the conversation.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘How to call wpforms actions’ is closed to new replies.