• Resolved nexusfred

    (@nexusfred)


    Hello, when I add the next lines in my child theme functions.php file, I get a Fatal error !

    action('acfe/form/validate_my-action',              $form, $action);
    action('acfe/form/validate_my-action/form=my-form', $form, $action);
    add_action('acfe/form/validate_my-action', 'my_form_validation', 10, 2);
    function my_form_validation($form, $action){ ...

    Fatal error: Uncaught Error: Call to undefined function action()

    What I’m doing wrong ?

    Thanks

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

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    The action() you see in the documentation are simply describing the available variations for the said hook. You should choose one variation and use add_action() in your code, as in the example code.

    For example, if you want to target all custom actions named my-action, in any form:

    add_action('acfe/form/validate_my-action', 'my_form_validation', 10, 2);
    function my_form_validation($form, $action){

    // ...

    }

    Or, if you want to target the custom action named my-action in the form named my-form:

    add_action('acfe/form/validate_my-action/form=my-form', 'my_form_validation', 10, 2);
    function my_form_validation($form, $action){

    // ...

    }

    Hope it helps!

    Have a nice day!

    Regards.

    Thread Starter nexusfred

    (@nexusfred)

    Hello, it doesn’t work.

    I have a form named “super-form” with a Custom action named “super-action”

    I call the form in a page with the shortcode [acfe_form name=”super-form”].

    In this form I only have one text field.

    In my functions.php page I wrote this code :

    add_action('acfe/form/submit_super-action', 'my_form_submit', 10, 2);
    function my_form_submit($form, $action){
    echo 'I do it ! <br>';
    die;
    }

    This should kill the process, but no. When submitting, I get a “Post updated” message instead.

    Whatever code I put in the function, this one is not executed.

    Advanced Custom Fields: Extended Version 0.9.0.6 installed.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    I just ran a test similar to your configuration, using your code, and it works fine on my end. Here is the video demo of my test.

    Please make sure that your Custom Action is correctly named super-action in the Form UI. Also please make sure your PHP code is correctly included in a file called somewhere either in your theme, or a custom plugin. If you’re not sure, just put it in your theme’s functions.php file.

    Here is the ACFE Form Json Export of my test. You can import it in the “ACF > Tools” admin menu, in the “Import Forms” tool (at the bottom of the page), if you want to test it by yourself.

    Hope it helps!

    Regards.

    Thread Starter nexusfred

    (@nexusfred)

    Thanks, I deleted the plugin folder and reinstalled it, and now it works… No idea what was wrong.

    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Hmmm, this is strange, maybe some plugins files couldn’t be uploaded during the initial install? I would recommend to check your FTP/server logs.

    Good to know it’s now working as intended.

    Have a nice day!

    Regards.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.