43. Multisite Compatibility | Field Forge - Custom Fields, Built for Speed
Download Log in

43. Multisite Compatibility

Developer Guide

Field Forge is fully compatible with WordPress Multisite. Each site in the network has its own set of custom tables.

Table Naming

On multisite, tables are prefixed per site:

text
wp_2_fieldforge_field_groups
wp_2_fieldforge_values
wp_2_fieldforge_options
wp_2_fieldforge_revisions

The main site uses the standard wp_ prefix (or wp_1_ on some installations).

Network-Wide Activation

When activated network-wide, Field Forge creates its tables for every site:

php
// Tables are created automatically on network activation.
// For new sites added later, Field Forge hooks into 'wp_initialize_site':
add_action( 'wp_initialize_site', function( $new_site ) {
    switch_to_blog( $new_site->blog_id );
    // Tables are auto-created on first admin visit
    restore_current_blog();
} );

Cross-Site Field Access

Field Forge values are scoped to each site. To read fields from another site:

php
// Read a field value from site #2
switch_to_blog( 2 );
$logo = get_field( 'site_logo', 'options' );
restore_current_blog();

// Use in a network header
echo '<img src="' . esc_url( $logo['url'] ) . '" alt="">';

Sharing Field Groups Across Sites

Use Local JSON to share field groups. Place JSON files in a mu-plugin directory:

php
// mu-plugins/shared-fieldforge/shared-fieldforge.php
add_filter( 'fieldforge/local_json/load_paths', function( $paths ) {
    $paths[] = __DIR__ . '/fieldforge-json';
    return $paths;
} );

This makes the same field groups available on all sites without per-site configuration.

Forge AI Assistant Online

Hi! I'm the Field Forge AI assistant. Ask me anything about the plugin — setup, features, troubleshooting, or development.

Just now
Powered by Forge AI · Browse docs