Home › Forums › Add-ons › Options Page › Need to "save options" once to make them working on a new multisite › Reply To: Need to "save options" once to make them working on a new multisite
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.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.