Home Forums Add-ons Options Page Override core WP settings via ACF options page?


Override core WP settings via ACF options page?

  • I’m building out a proof-of-concept SaaS using WP to power the backend. I’m using a mix of WP core functionality, two or three main plugins, and a lot of custom code.

    One thing that we need to simplify for users is managing settings. There are lots of things in core WP settings that we don’t want them to be bothered with. Same thing goes for the plugins.

    I’ve disabled some of the main options pages that aren’t needed (Reading, Writing, etc) but in some cases there are settings we don’t need (Tagline, Week Starts on, etc) interspersed with ones we do (Site Title, Timezone).

    To help simplify this, I considered just building out our own custom settings pages using ACF – which brings me to my question:

    Can a ACF options page/fields be configured to override core WP settings?

    I assume this can’t be done natively via standard ACF configuration options, but wondering what’s involved or if anyone has done this?

    I figure upon saving the ACF Options page we’d have to write those settings out to the appropriate core/plugin meta data and then read those core/plugin values back in when loading up the ACF options page (so the options page displays current data). Is this more trouble than it’s worth?

    Any examples or thoughts are much appreciated!

  • I can’t give you details on every possible WP option, but generally you’re got 2 choices.

    1) Use an acf/save_post filter when the options page is saved, take the values from the ACF fields and update the WP option value. Exactly how you’d do this update would likely be different depending on the option you’re overwriting. For example, the “Blog Title” field in the options table as “blogname”.

    update_option('blogname', get_field('my_blog_name_field', 'options'), true);

    2) The second option is to override the WP options in code. For example

    add_filter('option_blogname', 'my_override_blog_name', 10, 2);
    function my_override_blog_name($value, $option) {
      $value = get_field('my_blog_name_field', 'options');
      return $value;

    Like I said, the above is only one example. You’d have to investigate how/where each of the options you want to override is saved and what can be done to override them. More than likely I would go with the first option of updating the actual WP options when the options page is saved. The reason for this is that 1) the DB locations of these options is not likely to ever change (while the filters for overriding them after the fact might) and 2) using the first method will work for the front end of the site even if ACF is deactivated.

  • Thanks John for the detailed response!

    Method #1 is pretty much what I was anticipating would need to be done and is manageable.

    The biggest thing I was wondering is if there’s a way to read the actual values back from the database and populate ACF with them in the admin interface when the user visits the options page next time?

    Exactly like save_post but on the other end of the edit process.

    If we have the normal settings pages disabled I don’t anticipate that there’d be a situation in which the two got out of sync, but in the event that a plugin or some other piece of the system would update the value of the options I’d prefer, for completeness, to make sure that new value is represented again in the ACF options page when opened.

  • You can use the acf/load_value filter to get the WP setting and return that.

  • That’s perfect, thanks John!

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

The topic ‘Override core WP settings via ACF options page?’ is closed to new replies.