• Resolved deeveedee

    (@deeveedee)


    First, let me say that I am quite impressed with Ninja Forms. Outstanding work!

    I would like to pass data to the success message, such that the success message displays the data as part of the message. For example, if the form is a helpdesk form, I would like the success message to return a ticket number (e.g. “Your ticket number is X,” where X is the data passed to the success message.

    Is there a filter that I can use to achieve this? Thank you very much for your great plugin.

    The page I need help with: [log in to see the link]

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Contributor Zach Skaggs

    (@wpnzach)

    This can be done by extending our merge tag system, which is documented here: https://developer.ninjaforms.com/codex/merge-tags/

    Unfortunately, custom development isn’t supported by us, but that documentation should be a good place to get you started. If you’re just looking to add form data to the success message and not your own data, that is covered in our documentation here: https://ninjaforms.com/docs/success-message/

    Because we only check these forums once per week, we strongly encourage you to reach out to us here with any followup questions in order to get a timely response: https://ninjaforms.com/contact/ There, we offer support free support directly to our Ninja Forms users with significantly more privacy and a faster response time.

    Thread Starter deeveedee

    (@deeveedee)

    @wpnzach – Thank you for the quick reply!

    Thread Starter deeveedee

    (@deeveedee)

    I have tried the merge-tag example posted at https://developer.ninjaforms.com/codex/merge-tags/, but it is not working. The merge-tag {my:foo} is not found when I attempt to add it to my form’s success message. Has anyone successfully duplicated this example or does anyone have another working example of a Ninja Forms custom merge-tag?

    Details:
    I followed the example and exactly duplicated the My_MergeTags class definition in file class.mergetags.php in my child theme directory and inserted the following code in my child theme’s functions.php:

    add_action( 'ninja_forms_loaded', 'my_register_merge_tags' );
    function my_register_merge_tags() {
      require_once 'class.mergetags.php'; 
      Ninja_Forms()->merge_tags[ 'my_merge_tags' ] = new My_MergeTags();
    }
    

    When I attempt to add the merge-tag {my:foo} to my form’s success message, the merge-tag is not found and the title ‘My Merge Tags’ does not appear in the merge-tag category listing (under ‘Fields’ ‘WordPress’ ‘Form’ and ‘Other’).

    Thread Starter deeveedee

    (@deeveedee)

    @wpnzach – there appears to be a bug in the action ninja_forms_loaded – I have duplicated the findings in the Jul 28 post here: https://github.com/wpninjas/ninja-forms/issues/1910

    If I hook action nf_init instead, my custom merge-tag is available.

    Thread Starter deeveedee

    (@deeveedee)

    After further testing (after implementing the ‘nf_init’ bug fix above), I’m still not certain that Ninja Forms does what I need. I have a form that implements a custom action. The custom action produces a numeric value that I want to display in the success message. Is this possible with Ninja Forms?

    Details:
    I am attempting to use Ninja Forms to submit customer requests to a helpdesk database that is independent of my WordPress website. I am able to hook ninja_forms_processing with my own custom callback to submit the form data to the helpdesk database. The result of my custom call back is a numeric helpdesk ticket number. Separately, I have implemented a merge tag that displays custom information in the success message. I would like to pass the ticket number resulting from the custom call back to the merge tag displayed in the success message. However, this does not seem possible given that the return value from the custom action must by VOID.

    Any suggestions?

    Plugin Contributor klhall1987

    (@klhall1987)

    Hey @deeveedee,

    I was unable to replicate the issue with the code. Here is the custom plugins I created if you’d like to take a look at it(https://drive.google.com/file/d/0B_bF3V9Cefm6NVVfeWVaQmFISTQ/view?usp=sharing).

    Would you mind looking over this and letting me know if it works on your install? It’s the exact same code from the developer docs. I think we need to do a better job of explaining that the two code snippets can’t be in the same file because we are running a class that is abstracted from and is dependent on the data ninja forms being loaded, before we start running the merge tag class. I hope that makes sense.

    As for your other question, I think the best place to get help would be from our developer slack community. Our slack community a group moderated by our developers where you can ask questions and they(or other members of the community) will do their best to help you out. We try to make sure everyone gets the help they are looking for, but I cannot guarantee you’ll always get an answer.

    Developer Slack Community:
    https://developer.ninjaforms.com/slack/

    Thanks,

    Kenny
    WP Ninjas LLC

    Thread Starter deeveedee

    (@deeveedee)

    @klhall1987 – Thank you for the reply. You have helped me to better understand your documentation. I did correctly define my custom merge tag class in its own PHP file, but I didn’t create a separate plugin file for the merge tag. I specified the add_action( 'ninja_forms_loaded', 'my_register_merge_tags' ); in my functions.php file.

    I have never developed my own plugin which is why I didn’t understand this from your documentation. If I’m correct in understand you and that a custom merge tag needs to be its own plugin, that is indeed the problem with my implementation. Thank you for your help.

    I will take your advice and post my question in the Developer Slack Community. Thank you.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Passing data to the success message’ is closed to new replies.