• Resolved Fantou

    (@fantou)


    Hello,

    Is it possible to use the API PostMessage with Forminator ? I am aware I will have to add some code but I would like to know what is possible with Forminator

    My scenario will be this one :
    -Create a form on the site : mysite.com with only an postal adress
    -This postal adress must be sent to app.mysite.com

    Like this, the visitor will just have to enter its adress and it will have directly the anser, instead of having to click on a button to go to the app AND there, enter its address.

    I think API postmessage could be an interessant solution. What do you think about it ? Could it be possible ? Is there already an “option” in Forminator for this ?

    Have a nice day

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @fantou,

    I hope things are going well for you.

    The details mentioned above are quite unclear to me. However, let me share what I understood from it.

    For example, if you want to transfer details from one site to app site and are using both ends of the Forminator form, you can avoid manual entry the second time by utilizing pre-populated form field values feature. This guide provides detailed instructions on how to configure this feature https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#pre-populate-form-field-values.

    If you’d like something else, please share your goal and a better example of what you’re trying to achieve.

    Is there already an “option” in Forminator for this ?

    Currently, we offer some API Webhook Integration, which can be found here: https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#integrations, Further for manual coding you can find more details here:
    https://wpmudev.com/docs/api-plugin-development/forminator-api-docs/.

    Please let us know if you require any additional information or assistance.


    Kind Regards,
    Imran Khan

    Thread Starter Fantou

    (@fantou)

    Hi @wpmudev-support9

    Thank your for your quick answer and I hope all goes well for you too. Sorry it was unclear

    I would like to use this method : https://medium.com/somos-pragma/an-alternative-for-sending-data-to-another-place-or-to-localstorage-postmessage-dc7e72e7ea11
    for connecting my website and my app. Unfortunatly, the app does not have Forminator in it, it is custom.

    So I’ve think about this API Postmessage :
    -on the site, Forminator will “catch” the adress (but I have to add a code for this. Unless there is already a setting for this, this is the point of my quetsion 🙂
    -The adress will be sent to the app via the “code”.

    I know it is not very clear, I don’t have an example to show this, sorry ^^;

    With the Forminator’s API, I don’t see how to do this : in the app, I can configure the “get_form_fields()” but how trigger it as soon as someone enter an postal adress on the site ?

    That’s why I think the API Postmessage is a easier, what do you think of it ? 🙂

    Have a nice day !

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @fantou

    Thank you further details.

    We have different ways here, let me try to cover them so you can decide which fits better your need.

    – Via Backend:

    You can use some Forminator hooks, for example, if you want to trigger something after Forminator save the data in database you can use:

    $entry = Forminator_Form_Entry_Model::get_latest_entry_by_form_id( $form_id );  
    
    along
    
    add_action ( 'forminator_form_after_handle_submit', 'function_name', 10, 2 );
    add_action( 'forminator_form_after_save_entry', 'function_name', 10, 2 ); 
    
    Params $form_id and $response

    In app.mysite.com needs to have a POST endpoint to receive that data, you can use wp_remote_post function.

    – Via front end

    The API postMessage() can work in this case, you can trigger the Post message after the form submit, I believe the event described here https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#form-data-not-sent-to-gtm can help you. But I see this method would be too weak depending on your needs, the backend approach is a better idea.

    – Via Webhook, Similar to first option you would need the app. to have an POST endpoint to receive the event request, the benefit of this approach is you don’t need to worry with the Form as it will trigger the data out of box, you just need to worry on building your endpoint.

    You can test webhook data using https://webhook.site/

    With that said, as Imran mentioned, creating the code would be beyond our support scope, but I believe the above gives you a better idea to how to proceed.

    Best Regards
    Patrick Freitas

    Plugin Support Patrick – WPMU DEV Support

    (@wpmudevsupport12)

    Hi @fantou

    Thank you further details, It is more clear now.

    We have different ways here, let me try to cover them so you can decide which fits better your need.

    – Via Backend:

    You can use some Forminator hooks, for example, if you want to trigger something after Forminator save the data in database you can use:

    $entry = Forminator_Form_Entry_Model::get_latest_entry_by_form_id( $form_id );  
    
    along
    
    add_action ( 'forminator_form_after_handle_submit', 'function_name', 10, 2 );
    add_action( 'forminator_form_after_save_entry', 'function_name', 10, 2 ); 
    
    Params $form_id and $response

    In app.mysite.com needs to have a POST endpoint to receive that data, you can use wp_remote_post function.

    – Via front end

    The API postMessage() can work in this case, you can trigger the Post message after the form submit, I believe the event described here https://wpmudev.com/docs/wpmu-dev-plugins/forminator/#form-data-not-sent-to-gtm can help you. But I see this method would be too weak depending on your needs, the backend approach is a better idea.

    – Via Webhook, Similar to first option you would need the app. to have an POST endpoint to receive the event request, the benefit of this approach is you don’t need to worry with the Form as it will trigger the data out of box, you just need to worry on building your endpoint.

    You can test webhook data using https://webhook.site/

    With that said, as Imran mentioned, creating the code would be beyond our support scope, but I believe the above gives you a better idea to how to proceed.

    Best Regards
    Patrick Freitas

    Thread Starter Fantou

    (@fantou)

    Hi @wpmudevsupport12

    Thanks for all these valuables informations ! It will help me a lot ! 🙂

    Have a nice day !

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘API PostMessage’ is closed to new replies.