• Resolved devtat

    (@devtat)


    I’ve added Buttons with the Ajax-enabled hooks, like ‘acfe/fields/button/name=action_1’, but how do I actually run my custom functions without making an Ajax call?

    The documentation says “the button will natively submit the current form”, which doesn’t really tell me anything, like:
    – How are these values sent/accessed? (I just need the post_id and button name)
    – Can I still hook specific actions to different Buttons in a non-Ajax submissions?
    – Does the Button type (button|submit) matter? etc.

    My main issue is that I’m modifying the Post Status of the post the Buttons are attached to, so I need the post to be refreshed/redirected after a Button is clicked.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback! The post edit screen in the WordPress admin area is one big <form>...</form> tag. All WordPress post settings and ACF fields are rendered inside that tag, which includes the ACF Extended button field. In HTML, any <button></button> or <input type="submit" /> tags will submit the current form on click.

    In the post edit screen of WordPress that means the general form will be submitted, which is basically the same as if the user clicked the primary “Update” button on the top right corner. This will trigger all WordPress submission logic (hooks, filters etc…), and also ACF submission logic (since there are ACF fields in the form).

    So you can use any WordPress submission hook (See this Stackoverflow answer), or the acf/save_post hook which handle all post edit submission logic, to add your own logic. See documentation: https://www.advancedcustomfields.com/resources/acf-save_post/

    Hope it helps!

    Regards.

    Thread Starter devtat

    (@devtat)

    Thanks! ??

    I ended up having to hook into both 'acf/save_post' and 'acf/pending_post', and switch to a normal select dropdown to cover the many different actions I wanted there.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I’m glad to hear that you made it works! Please note that the acf/pending_post hook doesn’t exists tho.

    Have a nice day!

    Regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘ACFE Button non-ajax hook/usage?’ is closed to new replies.