Bug report - Multinetwork compatibility

Hello,

I have found a problem on Ultimate Branding plugin. It's not compatible with Multinetwork ("Login Image" and "Custom Multisite Favicons" modules).

My proposed fix: replace the 3 occurrences of

switch_to_blog(1);

with

$mainblogid = wp_get_sites(); switch_to_blog( $mainblogid[0]['blog_id'] );

2 occurrences in ultimate-branding-files/modules/login-image.php
1 ocurrence in ultimate-branding-files/modules/favicons.php

obs: this is a partial fix. It will only work when the id of a main blog of a given network is the lowest id between all the blogs in that network. Works for me but will still fail otherwise. I am not sure how to obtain the main blog id of a given network by another method. :slight_frown:

  • Rupok

    Hi Renato

    Hope you had a wonderful day.

    It's not compatible with Multinetwork

    Do you mean WordPress Multisite Network with Multinetwork? Is it not showing custom login image for Multisite Network? Can you please describe the process so we can also regenerate and confirm the conflict?

    Thanks for suggesting the partial solutions. I'll forward these to our developer as soon as I can confirm the issue.

    Have a nice day. Cheers!

    • Renato

      Hi, Rupok

      I mean WordPress Multinetwork - as in https://premium.wpmudev.org/blog/network-of-multisite-networks/

      Steps to reproduce:

      1. Install WP
      2. Enable Multisite (name the network "Main Network")
      3. Create a subsite - it will have blog id 2, naturally...
      4. Install WP Multi Network plugin (https://wordpress.org/plugins/wp-multi-network/)
      5. Create a "Secondary Network" (now you have the main Network and the newly created "Secondary Network", whose main blog id is id 3)
      6. Create another subsite on "Secondary Network".

      At this point, you will have:
      Main Network >> blogs 1 [main] and 2 [additional subsite]
      Secondary Network >> blogs 3 [main] and 4 [additional subsite]

      7. Install Ultimate Branding plugin, network-activate it and enable the modules "Login Image" and "Custom Multisite Favicon" (note: the plugin needs to be network-activated on each Network individually, as any plugin)
      8. You CAN define the image/favicon for the "Main Network" (whose main blog id is 1)
      9. The Bug: you CAN'T define the image/favicon for the "Secondary Network" (whose main blog id is other than 1, as assumed on the modules code on the "switch_to_blog(1)" call)

      With the proposed fix, you can define the image for the "Secondary Network".

      However, it's a partial fix. You can't redefine the image/favicon files again in case you move the subsite id 2 from "Main Network" to "Secondary Network", because it will be looking as this:

      Main Network >> blogs: 1
      Secondary Network >> blogs 2, 3 [main] and 4
      (it will try to save/read the file from blog 2 upload directory, instead blog 3, which is the main for the network).

      I will continue looking for a way to permanently fix it (obtain the main blog id on a given network in a way it works for cases where the ID is not the lowest within the set of blog's ids in the network), so please let me know in case you find it, so I don't waste my time unnecessarily. :slight_smile:

  • Kasia Swiderska

    Hello Renato,

    Thank you for detailed instruction how to replicate this issue. However at this moment I can move this thread to the Features&Feedback section and drop line to developer because Ultimate Branding supports only Multisite, not Multi Networks.
    Hopefully more members will support this so support for multi networks will be added in the future releases.

    kind regards,
    Kasia

  • Renato

    I have found a permanent fix for this.

    Please, please, please add it to the next plugin release, as I have fixed it by directly modifying the plugin files on my end.

    Replace the 3 occurrences of:

    switch_to_blog(1);

    with:

    $mainblogid = function_exists( 'get_main_site_for_network' ) ? get_main_site_for_network() : '1'; switch_to_blog($mainblogid);

    2 occurrences in ultimate-branding-files/modules/login-image.php
    1 ocurrence in ultimate-branding-files/modules/favicons.php

    The function get_main_site_for_network is provided by the Multi-Networks plugin (https://wordpress.org/plugins/wp-multi-network/) :wink:

  • Rupok

    Hi Renato,

    Thanks a lot for sharing the fix with us. I'm so sorry for the delay from our end. I've pinged our developer personally and I'll update you as soon as I get something from him regarding this. I believe, he will come up with a feedback soon.

    Please keep in mind, our developers work round the clock and they have to deal with lots of critical issues and other things. So it may take a little while for them to check this and provide a feedback.

    Have a nice day. Cheers!
    Rupok