Support

Account

Home Forums Bug Reports Fatal Error 4.3.0 acf_field not found

Solving

Fatal Error 4.3.0 acf_field not found

  • Hello Elliot,

    i’ve made a theme for WordPress and i have included the plugin and all addon-ons. All work fine since version 4.2.2

    I get this error on version ACF 4.3.0:
    Fatal error: Class 'acf_field' not found in …/acf-gallery/gallery.php on line 4

    After a little search in the new ACF 4.3.0 i found the problem in acf.php:

    add_action('plugins_loaded', array($this, 'include_before_theme'), 1);

    If i change to this:
    add_action('after_setup_theme', array($this, 'include_before_theme'), 1);

    All work fine but add ons and options disappears, and the exported php not work

  • Hello @minimac, Elliot

    I have a similar problem on my website. I export all acf fields but i require_once in my plugins and there not appears. What’s your recommandation to require fields ?

    Which hook should I calibrate? ‘init’ ?

    Thanks

  • Ok, i found the solution. (but an UGLY solution, @elliot surely will do it better)

    // includes
    $this->include_before_theme();
    //add_action('plugins_loaded', array($this, 'include_before_theme'), 1);
    add_action('after_setup_theme', array($this, 'include_after_theme'), 1);

    just disabled plugins_loaded

  • I don’t think this is the good solution. This hook was introduced in 4.3.0

  • @minimac How do you include your acf files with register_field_group ?
    Which hook do you use ?

  • I was having issues with “the_field” giving fatal errors, not sure if it is related. I ended up using an if statement to prevent the call from happening if the_field was undefined (which is probably a good thing anyway)… not sure if its related…

  • My solution was to register all my fields on INIT hook 😉 or plugins loaded but with priority to 20 because ACF was placed on 1

  • Hi @minimac

    Looks like the issue is caused when ACF is included in a theme rather than included in the plugin.

    This causes some of the core files to not be included and causes the error.

    I’ll do some work on this and report back soon.

    Thanks
    E

Viewing 10 posts - 1 through 10 (of 10 total)

The topic ‘Fatal Error 4.3.0 acf_field not found’ is closed to new replies.