How to make New Blog Templates work with WP Multi Network?

Hello,

The plugin is not behaving like the others do in conjunction with: http://wordpress.org/plugins/wp-multi-network/, i.e. in Wordpress MU, with the WP Multi Network plugin. I can manage each plugin separately on each network but not with the New Blog Templates plugin.

Let me give you an example:

I first create a blog template in sophrologues.org and mark it as default, now every new blog I create clones this template.
When I switch to votresophrologue.fr (the other network under the same WP MU installation), I see the template as default but when I create a new blog, it does not clone the template.

I think the issue is coming from the fact that the blog id used when on one network does not exist (or is out of bounds) on the other network.

The solution would be to have New Blog Templates behave like the other plugins, i.e. manage each network separately.

Thanks for your help!

Jamal

  • PC

    Hello Jamal,

    Thanks for your post.

    In WP Multi network each plugin has to be activated separately on each network are you sure if that is the case ?

    There is no written compatibility however it would be great to get the plugin working on the Multi network setup.

    So, can you tell me if you have activated the plugin separately in all the networks and create templates of each of them separately ?

    Please advise so that we can find out the best way out and get this solved. !

    Cheers
    PC
    Sales &Support

  • Jamal

    Hello PC (?),

    Yes I am aware of that. The problem is that New Blog Templates once activated on one network gets activated in all the networks.

    That is one part on the problem. The other issue is that the blog templates created are heavily dependent on one network (with the blog id) but they appear in the other networks although they cannot indeed be used (as that blog id does not exist in this network). The thing is that WPMU seems to be having a global autoincrement on the blog id, that is you cannot have the same blog id in both networks and hence cannot circumvent the problem stated above.

    Here is what I did last time:

    - I noticed that there was an old version (1.1.1) dying in the mu-plugins folder so I removed it
    - I then installed the latest version of New Blog Templates on one network
    - the old templates that were created with the old version now appeared via the UI
    - I created a new template and tested the workflow marked it as default and it worked as advertised
    - I then switched to the other network:
    i) the extension was activated
    ii) the template I had just created was visible
    iii) each new blog created on this network does not use the template

    Since there was cruft from the old version I then:

    - removed all the templates
    - deactivated New Blog Templates
    - removed New Blog Templates

    I then proceeded to reinstall New Blog Templates (by the way I had to do it via FTP this time as the WPMU DEV dashboard would not let me install it) and:

    - I installed the latest version of New Blog Templates on one network
    - I created a new template with options selected:
    * Wordpress Settings, Current Theme, and Active Plugins
    * Pages + All Pages
    * Categories, Tags, and Links
    * Menus
    * Files
    * If selected, the dates of the posts/pages will be updated to the date when the blog is created
    (I am not interested in cloning posts)
    - I then marked it as default and it worked as advertised

    - I then switched to the other network:
    i) the extension was activated
    ii) the template I had just created was visible
    iii) each new blog created on this network does not use the template

    Cheers

    Jamal

  • Jamal

    Hello Ignacio,

    Sadly it does not work: I cannot create any template with this new version.

    On the first form "Create New Blog Template" it does seem that the blogs available belong to the correct network, i.e. I cannot select anymore a blog from the other network.

    But after having filled that form none of the things are passed on to the second form "Edit Blog Template" (neither Template Name nor Template Description). Anyway having filled all the fields and clicked the "Save template" button, I get the alert "Your changes were sucessfully saved!" (by the way there's a small typo, it's spelled "successfully") BUT nothing is appears in the Blog Templates list.

    By the way the screenshot that is displayed does not match the theme of the blog chosen as the template.

    Sorry!

    Best regards,

    Jamal

  • Jamal

    Hello Ignacio,

    If I simply click on the tab "Blog Templates", I get all these (I removed duplicated rows):

    [01-Oct-2013 08:13:04] Erreur de la base de données WordPress Table 'sophroloorg.wp_nbt_templates' doesn't exist pour la requête SELECT * FROM wp_nbt_templates WHERE network_id = 1 faite par require('wp-blog-header.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), include_once('/plugins/blogtemplates/blogtemplates.php'), require_once('/plugins/blogtemplates/blogtemplatesfiles/blog_templates.php'), blog_templates->__construct, blog_templates->get_options, blog_templates_model->get_templates

    [01-Oct-2013 08:13:04] Erreur de la base de données WordPress Table 'sophroloorg.wp_nbt_templates' doesn't exist pour la requête SELECT * FROM wp_nbt_templates WHERE network_id = 1 faite par require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), include_once('/plugins/blogtemplates/blogtemplates.php'), require_once('/plugins/blogtemplates/blogtemplatesfiles/blog_templates.php'), blog_templates->__construct, blog_templates->get_options, blog_templates_model->get_templates

    [01-Oct-2013 08:13:06] Erreur de la base de données WordPress Table 'sophroloorg.wp_nbt_templates' doesn't exist pour la requête SELECT * FROM wp_nbt_templates WHERE network_id = 4 faite par require_once('wp-admin/admin.php'), require_once('wp-load.php'), require_once('wp-config.php'), require_once('wp-settings.php'), include_once('/plugins/blogtemplates/blogtemplates.php'), require_once('/plugins/blogtemplates/blogtemplatesfiles/blog_templates.php'), blog_templates->__construct, blog_templates->get_options, blog_templates_model->get_templates

    [01-Oct-2013 08:13:06] Erreur de la base de données WordPress Table 'sophroloorg.wp_nbt_templates' doesn't exist pour la requête SELECT * FROM wp_nbt_templates WHERE network_id = 4 faite par require_once('wp-admin/admin.php'), do_action('toplevel_page_blog_templates_main'), call_user_func_array, blog_templates_main_menu->admin_options_page, NBT_Templates_Table->prepare_items, blog_templates_model->get_templates

    They repeat endlessly.

    Regards.

    Jamal

  • Jamal

    When I fil the first form I get these:

    [01-Oct-2013 08:20:12] Erreur de la base de données WordPress Table 'sophroloorg.wp_nbt_templates' doesn't exist pour la requête INSERT INTO wp_nbt_templates (blog_id,name,description,options,network_id) VALUES (2281,'Theme12','','a:6:{s:7:\"to_copy\";a:0:{}s:13:\"post_category\";a:1:{i:0;s:14:\"all-categories\";}s:11:\"copy_status\";b:0;s:17:\"block_posts_pages\";b:0;s:9:\"pages_ids\";a:1:{i:0;s:9:\"all-pages\";}s:12:\"update_dates\";b:0;}',4) faite par require_once('wp-admin/admin.php'), do_action('admin_init'), call_user_func_array, blog_templates_main_menu->admin_options_page_posted, blog_templates_model->add_template

    [01-Oct-2013 08:20:13] Erreur de la base de données WordPress Table 'sophroloorg.wp_nbt_templates' doesn't exist pour la requête SELECT * FROM wp_nbt_templates WHERE ID = 0 faite par require_once('wp-admin/admin.php'), do_action('toplevel_page_blog_templates_main'), call_user_func_array, blog_templates_main_menu->admin_options_page, blog_templates_model->get_template
    [01-Oct-2013 08:20:13] PHP Warning: array_merge(): Argument #1 is not an array in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/model.php on line 249
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 183
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 202
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 206
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 334
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 334
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 334
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 334
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 334
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 334
    [01-Oct-2013 08:20:13] PHP Warning: in_array() expects parameter 2 to be array, null given in /var/www/sophrologues-org/wp-content/plugins/blogtemplates/blogtemplatesfiles/admin/main_menu.php on line 334
    [01-Oct-2013 08:20:13] Erreur de la base de données WordPress Unknown column 'network_id' in 'where clause' pour la requête SELECT ID FROM wp_nbt_templates_categories WHERE is_default = '1' AND network_id = 4 faite par require_once('wp-admin/admin.php'), do_action('toplevel_page_blog_templates_main'), call_user_func_array, blog_templates_main_menu->admin_options_page, blog_templates_model->get_template_categories, blog_templates_model->get_default_category_id

    And the one I mentioned before are always triggering too.

    I think you have a problem during set up/tear down (install/uninstall) of your plugin.

    Regards.

    Jamal

  • Ignacio

    Hi @Jamal.

    That killed me :slight_frown:.

    Could be possible to get access to your site, FTP and DB?

    Can you please send in:

    - Mark to my attention
    - Link back to this thread
    - Include admin/network access
    - Include cPanel (I will need to look at the DB so need PHPMyAdmin or similar)
    - Include FTP
    - Include any relevant URLS for your site

    https://premium.wpmudev.org/contact/
    (Select "I have a different question" option)

    Regards.
    Ignacio.

  • Jamal

    Hello Igniacio,

    I am sorry but I cannot give you ssh or ftp access to the site.

    I can give you admin access to the network for a while but that's all.

    I have only command line access to the DB through ssh and with not enough privileges for mysqldump, however I can give you structural information on some tables.

    At first I thought that the wordpress user had not enough privileges to create the required tables for the plugin, but I've just created a test table using those same credentials.

    Regards,

    Jamal

  • Ignacio

    Yes, here's the SQL:

    CREATE TABLE wp_nbt_templates (
    				ID bigint(20) NOT NULL AUTO_INCREMENT,
    				blog_id bigint(20) NOT NULL,
    				name varchar(255) NOT NULL,
    				description mediumtext,
    				is_default int(1) DEFAULT 0,
    				options longtext NOT NULL,
    				network_id bigint(20) NOT NULL DEFAULT 1
    				PRIMARY KEY  (ID)
    			      )

    I'll try to check if the script is well written for the next version but it worked for me so that was weird.

  • Jamal

    Can I also get the SQL for wp_nbt_templates_categories?

    I still get:

    [01-Oct-2013 09:13:24] Erreur de la base de données WordPress Unknown column 'network_id' in 'where clause' pour la requête SELECT ID FROM wp_nbt_templates_categories WHERE is_default = '1' AND network_id = 4 faite par require_once('wp-admin/admin.php'), do_action('toplevel_page_blog_templates_main'), call_user_func_array, blog_templates_main_menu->admin_options_page, blog_templates_model->get_template_categories, blog_templates_model->get_default_category_id

    Because:

    mysql> describe wp_nbt_templates_categories;
    +-----------------+--------------+------+-----+---------+----------------+
    | Field | Type | Null | Key | Default | Extra |
    +-----------------+--------------+------+-----+---------+----------------+
    | ID | bigint(20) | NO | PRI | NULL | auto_increment |
    | name | varchar(255) | NO | | NULL | |
    | description | mediumtext | YES | | NULL | |
    | is_default | int(1) | NO | | 0 | |
    | templates_count | bigint(20) | NO | | 0 | |
    +-----------------+--------------+------+-----+---------+----------------+

    Thanks!

  • Ignacio

    You'll then need two more tables:

    CREATE TABLE wp_nbt_templates_categories (
    				ID bigint(20) NOT NULL AUTO_INCREMENT,
    				name varchar(255) NOT NULL,
    				description mediumtext,
    				is_default int(1) NOT NULL DEFAULT '0',
    				templates_count bigint(20) NOT NULL DEFAULT '0',
    				PRIMARY KEY  (ID)
    			      )
    CREATE TABLE wp_nbt_categories_relationships_table_table (
    				cat_id bigint(20) unsigned NOT NULL,
    				template_id bigint(20) unsigned NOT NULL,
    				PRIMARY KEY  (cat_id,template_id),
    				KEY cat_id (cat_id)
    			      )

    Sorry for this painful proccess. I don't understand why the tables are not created for you.

    As soon as the tables are created try to create templates and test a little. Let's see if everything goes well.

    Regards.
    Ignacio.

  • Jamal

    Okay!

    I still get [01-Oct-2013 09:28:38] Erreur de la base de données WordPress Unknown column 'network_id' in 'where clause' pour la requête SELECT ID FROM wp_nbt_templates_categories WHERE is_default = '1' AND network_id = 4 faite par require_once('wp-admin/admin.php'), do_action('toplevel_page_blog_templates_main'), call_user_func_array, blog_templates_main_menu->admin_options_page, NBT_Templates_Table->prepare_items, blog_templates_model->get_template_categories, blog_templates_model->get_default_category_id

    But now I can create new templates!

    I am out of battery as of right now, so I'll get back to you this afternoon.

    Best regards,

    Jamal

  • Jamal

    Hey Ignacio,

    I used my own archive but I think it's the same unless you changed something else :slight_smile:

    Everything seems to be working except for the fact that the plugin is activated on every network. But that issue I really do not care about :slight_smile:

    - I can now select a template scoped to its network
    - I can create new templates
    - I can choose a default

    I get this error now:

    [01-Oct-2013 10:22:55] Erreur de la base de données WordPress You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')' at line 2 pour la requête SELECT * FROM wp_2281_terms
    WHERE term_id IN ( ) faite par require('wp-blog-header.php'), wp, WP->main, WP->query_posts, WP_Query->query, WP_Query->get_posts, do_action_ref_array, call_user_func_array, ust_wpsignup_page, require_once('/plugins/anti-splog/includes/ust-wp-signup.php'), validate_another_blog_signup, wpmu_create_blog, do_action('wpmu_new_blog'), call_user_func_array, blog_templates->set_blog_defaults, blog_templates->copy_menu

    But it does not seem to induce any misbehaviour...

    I'll make more extensive tests this evening.

    Thanks for your help.

    Regards.

    Jamal

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.