Support

Account

Home Forums Front-end Issues Select2 not pulling saved values on MultiSite Reply To: Select2 not pulling saved values on MultiSite

  • I finally tracked down the issue and thought I’d post my findings. The hack option didn’t work. I’ll post the code I used and you can tell me if that’s what you were suggesting I try. So far as I can tell, the breakdown happens on line 643 of class-acf-field-taxonomy.php in the render_field_select function. $this->get_terms doesn’t return any terms on subsites. It looks like i’ll have to pursue creating my own field that modifies the taxonomy field.

    function switchBeforeRender( $field ) {
    
    	if ( ! Site::isRoot() ) {
    		$currentSite = get_current_blog_id();
    		switch_to_blog( Site::getRootBlogId() );
    		set_transient( 'switchBeforeRender', $currentSite );
    	}
    
    }
    add_action( 'acf/render_field/type=select', 'switchBeforeRender', 8, 1 );
    
    function switchAfterRender( $field ) {
    
    	$originatingSite = get_transient( 'switchBeforeRender' );
    	$currentSite     = get_current_blog_id();
    	if ( $currentSite === 1 && $originatingSite ) {
    		delete_transient( 'switchBeforeRender' );
    		switch_to_blog( $originatingSite );
    	}
    
    }
    add_action( 'acf/render_field/type=select', 'switchAfterRender', 15, 1 );