Support

Account

Home Forums Add-ons Options Page Need to "save options" once to make them working on a new multisite

Helping

Need to "save options" once to make them working on a new multisite

  • Hey there 🙂

    I am using ACF-Pro in my multisite installation. Every time i add a new site, i need to “save Options” (In the Option Tree) one time to make get them working.

    I exported the ACF data to PHP and added it to a custom plugin. Maybe i need to run this plugin before (or maybe after?) the ACF plugin to get it recognized? If yes, how?

    Thanks 🙂

  • I know this is a little late, but if you still need help or for anyone else looking for similar information.

    If you are using ACF in a plugin that will be used on a multisite setup there are a few choices.

    1) in your plugin and wherever you are getting values from the options test to see if any value is set and if not then apply the default value.

    $option = get_field('my_field', 'options');
    if ($options === false) {
        $option = 'default value';
    }

    The above can potentially cause a problem if the field can return false and false is not the default value. In this case you could use the standard WP function get_option()

    $default_value = true;
    $field_name = 'my_field';
    $option_name = 'options_'.$my_field;
    $value = get_option($option_name, $default_value');

    The other choice it to insert all of the options for the new site when the site is created. This can be done by creating a function that runs on the WP hook wpmu_new_blog. This would be far more complicated. For more information see wpmu_new_blog in the WP Codex and documentation on the ACF update_field() function.

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

The topic ‘Need to "save options" once to make them working on a new multisite’ is closed to new replies.