Home › Forums › ACF PRO › Multisite Main Site Options Page Filter Child Site › Reply To: Multisite Main Site Options Page Filter Child Site
// load values into store list
// assumes it is only loaded on blog_id == 1
// assumes that the field is a select field that allows multiple choices
add_filter('acf/prepare_field/key=field_5e0a476fc3745', 'load_site_list');
function load_site_list($field) {
$sites = get_sites();
$choices = array();
if ($sites) {
foreach ($sites as $site) {
// not the main site
if ($site->blog_id == 1) {
continue;
}
switch_to_blog($site->blog_id);
$choices[$site->blog_id] = get_bloginfo('name');
restore_current_blog();
} // end foreach site
} // end if sites
$field['choices'] = $choices;
return $field;
} // end function
// see if current blog is selected
switch_to_blog( $main_blog );
$storelist1 = get_field('promotion_1_storelist', 'option');
restore_current_blog();
if (in_array(get_current_blog_id(), $storelist1)) {
// current site is selected
}
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.