• Resolved deeveedee

    (@deeveedee)


    I’ve been exploring multiple ways to create a custom success message action in real time based on the result of a custom callback in my WP Hook. After extensive exploration, it seems to me that there is a glaring hole in Ninja Forms 3.x. Shouldn’t there be a simple way to create a custom Success Message via a success_message_action() PHP function? The success_message_action() function should accept the success message string as one of the arguments.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter deeveedee

    (@deeveedee)

    In order to create a custom Success Message that is unique to each custom Action, I removed the WP Hook from my form (leaving only the Success Message Action as the single Action in my form) and moved my custom Action functinoality (formerly in the WP Hook callback) to a ninja_forms_run_action_settings filter. Now, after form submission, my action processing filter performs my custom Action and modifies the Success Message’s $action_settings['success_msg']before returning $action_settings.

    Using this technique, I can have a Success Message that displays the unique result of my custom Action. For example, my custom Action (now performed in the filter) submits the form data to an external helpdesk database which returns a helpdesk ticket number. Before exiting, the filter adds the helpdesk ticket number to the success message to be displayed to the user.

    Note that my custom Action which I moved to the filter needs read-only access to the form field values. Since I don’t know enough (yet) about Ninja Forms to directly access form data in the filter, my filter extracts the form field values from $action_settings['email_message']. This is the only way I could find to get the form field values using the data provided to the filter.

    Thread Starter deeveedee

    (@deeveedee)

    Marking this as resolved, since I was able to find a way to achieve the desired result with a custom ninja_forms_run_action_settings filter. I think Ninja Forms should provide an easier way to display real-time results from the WP Hook Action in the Success Message.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Ninja Forms needs a success_message_action() PHP function’ is closed to new replies.