Home › Forums › Feature Requests › Support Multisite options for all sites through sitemeta table › Reply To: Support Multisite options for all sites through sitemeta table
Seems I can’t edit my answer after some time. These are the filters I ended up using:
$field_key = 'foo';
add_filter( "acf/load_value/key=$field_key", function ( $original_value ) use ( $field_key ) {
$network_value = get_site_option( $field_key, null );
if ( ! is_null( $network_value ) ) {
// Return the value from the "sitemeta" table, if available
return $network_value;
} else {
// This will only happen if the field was never updated.
return $original_value;
}
} );
add_filter( "acf/update_value/key=$field_key", function ( $value ) use ( $field_key ) {
$old_network_value = get_site_option( $field_key, null );
// Replicate the field value to the "sitemeta" table
if ( is_null( $old_network_value ) ) {
add_site_option( $field_key, $value );
} else {
update_site_option( $field_key, $value );
}
$new_network_value = get_site_option( $field_key );
return $new_network_value;
} );
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.