Support » Plugin: Advanced Forms for ACF » Form Action url

  • Resolved darrellwilde

    (@darrellwilde)


    I need to integrate our booking form into a 3rd party software which recommends using AF plugin.

    They need me to change the ‘form action url’ and also include a ‘hidden’ key on the form.

    Can anyone point me in the right direction of this please.

    Thanks

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

Viewing 12 replies - 1 through 12 (of 12 total)
  • Thread Starter darrellwilde

    (@darrellwilde)

    UPDATE* Think i might have sorted the hidden field by using [advanced_form form=”form_***********” exclude_fields=”*fieldname*”]

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi!

    exclude_fields will remove a field from the form but won’t let you add a hidden input. The best way to do that is with this action: https://advancedforms.github.io/actions/af/form/hidden_fields/. Changing the form target URL can be done through the target argument: https://advancedforms.github.io/guides/available-arguments/#target.

    I hope that helps!

    Thread Starter darrellwilde

    (@darrellwilde)

    Thanks for the reply @fabianlindfors

    Can these extra parts just be added by shortcode or do I have to add them in the themes function.php?

    Sorry if this is a silly question.

    Thanks

    Plugin Author fabianlindfors

    (@fabianlindfors)

    The hidden field needs to be added with action I linked.

    The target argument on the other hand can be set either through the shortcode or using another filter: https://advancedforms.github.io/filters/af/form/args/.

    Thread Starter darrellwilde

    (@darrellwilde)

    Thanks @fabianlindfors which file would I need to add the action php to? I’ve never really used ACF before so any help would be great.

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Those are regular old WordPress filters so you should be fine adding it to your functions.php or similar!

    Thread Starter darrellwilde

    (@darrellwilde)

    Ah that’s perfect I’ll just add it to the themes functions.php and see how it goes!

    Thread Starter darrellwilde

    (@darrellwilde)

    Hey @fabianlindfors I tried using the above action:

    The best way to do that is with this action: https://advancedforms.github.io/actions/af/form/hidden_fields/.

    on my themes functions.php however it gave me an error.

    <?php
    
    function hidden_field( $form, $args ) {
    
        echo sprintf( '<input type="hidden" name="key" value="MTI4NzQxNTE1Nzl=");
    }
    add_action( 'af/form/hidden_fields/key=form_5efa926b56d9e', 'hidden_field', 10, 2 );

    I think this may have something to do with the add_action line.

    Could you take a look please?

    Thread Starter darrellwilde

    (@darrellwilde)

    UPDATE**

    I think i spotted the error @fabianlindfors this looks better. Just so i know i am right the hidden field I want to pass is MTI4NzQxNTE1Nzl=

    and the form key is form_5efa926b56d9e do you think this looks ok now to add to my themes function.php?

    function hidden_field( $form, $args ) {

    echo sprintf( ‘<input type=”hidden” name=”key” value=”MTI4NzQxNTE1Nzl=”>’);
    }
    add_action( ‘af/form/hidden_fields/key=form_5efa926b56d9e’, ‘hidden_field’, 10, 2 );

    • This reply was modified 1 year, 1 month ago by darrellwilde.
    Thread Starter darrellwilde

    (@darrellwilde)

    Ok, i’ve got a step further however it looks like it is trying to pull lots of other fields from acf which arent listed on my form. Do you know why it might do this @fabianlindfors

    My url is: https://www.activetalentagency.com/book/

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi again! Your code looks good but worth noting that you don’t need sprintf in your case!

    Regarding other fields being added, what location rule have you set for the unexpected fields in the ACF settings?

    Thread Starter darrellwilde

    (@darrellwilde)

    Thanks for the quick reply @fabianlindfors

    It is showing errors after submitting for fields I don’t even have listed in acf.

    For example my page at the moment has 3 acf fields which link to a form.

    The location rule is set: Form is equal to Booking (which is a form name I created).

    If you look at the page and submit some test data you will see the errors:

    https://www.activetalentagency.com/book/

    I only need to pass 3 fields (To test as i will need to add more later) which are “field_5efa929573e1c”:”Date”,”field_5efa92c373e1f”:”Name”,”field_625ea12bd6221″:”Email”

    • This reply was modified 1 year, 1 month ago by darrellwilde.
Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Form Action url’ is closed to new replies.