• Resolved Agent 3W

    (@agent3w)


    Hello,

    Does exists a way to register acfe forms without using admin UI ?

    I would like to load OR save in DB ACFE form from PHP.
    I’m creating a custom plugin using acfe forms, and I have to create all forms on each site instance manually…

    Thanks for your help and advices.

    Best regards.

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter Agent 3W

    (@agent3w)

    Hi,

    I finally found a way.

    I exported all forms in json from the dev site and put the file in the plugin.
    I’m using the acfe function acfe_import_form($args) to import forms on my plugin activation.

    I’m running something like that (inside my plugin class) :

    $acfe_forms_file = self::get_plugin_dir() . "acfe_forms_settings.json";
    if ( file_exists( $acfe_forms_file ) && function_exists( 'acfe_import_form' ) ) {
        acfe_import_form( file_get_contents( $acfe_forms_file ) );
    }
    • This reply was modified 2 years, 1 month ago by Agent 3W.
    • This reply was modified 2 years, 1 month ago by Agent 3W.
    Plugin Author Konrad Chmielewski

    (@hwk-fr)

    Hello,

    Thanks for the feedback!

    Yes, this is the good way to import a Form from PHP. Note that you should make sure to only run this function one time, to avoid importing and importing again the same form.

    In a future version of ACF Extended, you’ll be able to register forms in PHP only, making it more versatile. This new version is still work in progress, but we’re not so far from release. I can’t give ETA yet tho.

    Have a nice day!

    Regards.

    Thread Starter Agent 3W

    (@agent3w)

    Hello Konrad,

    good to know for registering forms from PHP in the future ??

    I’m running the import only on my plugin activation using register_activation_hook().

    Have a nice day too.

    Best regards.
    Joffrey

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create form from PHP (not with UI)’ is closed to new replies.