WordPress.org

Ready to get started?Download WordPress

Forums

NextGEN Gallery
switch_to_blog not supported (2 posts)

  1. chris@vendiadvertising.com
    Member
    Posted 1 year ago #

    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));

    http://wordpress.org/extend/plugins/nextgen-gallery/

  2. dejernet
    Member
    Posted 10 months ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic