Support » Plugin: NextGEN Gallery - WordPress Gallery Plugin » switch_to_blog not supported

  • cjhaas


    I noticed that in nggallery.php in the function define_tables that table names are cached upon loading the plugin.

    // add database pointer
    $wpdb->nggpictures = $wpdb->prefix . 'ngg_pictures';
    $wpdb->nggallery = $wpdb->prefix . 'ngg_gallery';
    $wpdb->nggalbum = $wpdb->prefix . 'ngg_album';

    Unfortunately this means almost any attempt to use switch_to_blog() in a multisite environment won’t work. For instance, on plugin load of site 2 the variables will look like wp_2_ngg_pictures. Calling switch_to_blog(1) never updates these cached variables so queries still assume site 2.

    switch_to_blog() calls an action at the end that you can hook into. Any chance of adding support for this? You should be able to add this directly to nggLoader (I did in my copy).

    add_action('switch_blog', array(&$this, define_tables));

Viewing 1 replies (of 1 total)
  • If you don’t want to manually update NGG, you can just call the $ngg->define_tables(); after a switch_to_blog or restore_current_blog command. This way, if you update NGG you won’t lose your bugfix.

    This is something that the NGG guys should fix, some day.

Viewing 1 replies (of 1 total)
  • The topic ‘switch_to_blog not supported’ is closed to new replies.