Support

Account

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
    }