The MU forums have moved to WordPress.org

Automatically have plugin's activated for new blogs? (26 posts)

  1. justmsw
    Member
    Posted 17 years ago #

    I've searched around the forum, but I can't exactly find an answer, hoping you can help me out.

    I've got plugman installed and working, but I noticed back at the author's site that someone stated they figured out how to make it "automatically activate" all plugins for new users (some option that you can turn on or off).

    (see: https://samson.blog.asu.edu/plugman/?triedWebauth=1 )

    Does anyone know how I can do this? I've been looking around the codes (but am not a big coder) and this site, but nothing so far ...

    Thank you!

  2. justmsw
    Member
    Posted 17 years ago #

    Maybe I made that post a little too difficult for average scientists to understand.

    So, let me go another route and lets talk code....

    First of all, let me just say that wordpress multi-user Nightly build is very well done and anyone can tell that major corporations are using this, but it is obvious that they are coding it to their structure.

    However, let me say, who in their right mind did not incorporate the auto plugin activation for new plugins?

    I mean you guys go to all that trouble to invent a simple multi user blogging system and yet, you dont even incorporate an option for new blogs that are created in the multi user environment to come with the plugins already activated for new blogs? Do you guys understand that the site admin is unable to disactivate the WP Backend Plugin Menu for all users! Because, if we do, then the user that created the new blog in the wpmu will have to either activate the plugins themselves or rely on a site admin to do it for them.

    How ridiculous is that! Talk about security risks out the flippin wazzoo!

    Anyways, I'm not here to lecture, but I would like to give a suggestion, please incorporate the auto plugin activation for newly created mu blogs.

    What this means is, that what wpmu needs is the ability to already have the plugins activated and ready to go after a new user has signed up for the new blog, without the user or site admin having to activate manually for them.

    Why did you guys not think of this! What happens when you have 2000 users sign up for blogs on your wpmu and then you expect these users to activate the plugins themselves or you expect the site admin to have to go through each blog to activate them for their users. Are you kidding me?

    I know the MU Plugin Management (plugman) does very well for global purposes. But lets imagine you had to globally activate 100 blogs for that day manually. Now you think this is a simple process... But, oh wait... how much resource would it take to globally activate and continue to reactive all blogs for plugins to take affect.

    This wpmu was not well thought out in regards to this type of process. We're talking major server crashes, server hangs and more chances for users to unknowningly screw up there blogs. Especially if your aiming these mu blogs to a young audience. Not everyone is a bloody genius.

    Regardless, even if you take out the plugman management code that just makes the situation worse, since your default plugins that you inputted for admin will never activate, unless you manually activate for each newly created wpmu blog. Thats just nuts.

    Anyways, lets discuss code. Since, most of you have come here to read about that.

    Most likely there is a way to activate this type of policy either by a hook or within one of the wpmu php files.

    The files to mostly look at it, would be:

    wp-admin/upgrade-schema.php
    wpmu-blogs.php
    and
    wp-signup.php

    The reason to look at the upgrade-schema is because that is the default sql database information that is set for all newly created blogs in the wpmu database. Any information that is in this file will be the main settings for the wpmu blog, since the admin blog is the default mu blog, it stands to reason to grab the information from the admin default mu settings in the sql database.

    However, most web hosts are so dang cheap that its not possible for some server hosts to allow you access to edit the sql database itself. Leaving most server owners with only the possibility of editing certain files in the ftp.

    Which is fine, the code could be implemented in the schema.php file to allow for plugins to be automatically activated off of every newly created wpmu blog.

    So, without the ability to edit the sql database itself, I am left with editing the schema php file. Changing the settings to the schema file yields interesting results, however, after changing the schema file, if the proper commands are not inputted correctly in that file; that those newly created blogs will use the schema updated commands, which if the commands are wrong could lead to future corrupted blogs based upon the hacked schema php.

    So, obviously there has to be an easier way, but so far, if the wordpress authors havent figured it out, then it looks like a dark road for the future of wordpress mu blogging.

    Now moving on,

    without access to sql information or hacking it per say, the only way to get that information is by using the backup utility for wordpress which is backup plugin. Which most people wont want to use it since, if you leave backup plugin on, it allows your non site admins and other blog owners to back up and steal/hack your entire blog information. Unbelievable.

    The backup plugin gathers the sql formatted information and then downloads it to your computer in tz/sql.

    The file can be edited by notepad. However, the actual parameter code for the plugins in the active list under SITEADMIN>BLOGS>ACTIVE PLUGINS list shows exactly the proper information on how to input this into the active plugins list on the schema php. While it gives the entire command:
    (Keep in mind that for this post, I replaced the plugin names.)

    INSERT INTO wp_1_options VALUES (39, 0, 'active_plugins', 'Y', 1, 'a:21:{i:0;s:16:"plugin1.php";i:1;s:32:
    "plugin2.php";i:2;s:11:
    "plugin3.php";i:3;s:13:
    "plugin4.php";i:4;s:22:
    "plugin5.php";i:5;s:14:"plugin6.php";i:6;s:20:
    "plugin7.php";i:7;s:13:"plugin8.php";i:8;s:13:
    "plugin9.php";i:9;s:12:"plugin10.php";i:10;s:14:
    "plugin11.php";i:11;s:19:"plugin12.php";i:12;s:20:
    "plugin13.php";i:13;s:9:"plugin14.php";i:14;s:23:
    "plugin15.php";i:15;s:11:"plugin16.php";i:16;s:16:
    "plugin17.php";i:17;s:14:"plugin18.php";i:18;s:26:
    "plugin19.php";i:19;s:12:"plugin20.php";i:20;s:15:
    "plugin21.php";}', 20, 8, '', 1, 'yes') ;

    So, as you can tell from above, the code most likely is in its final form and probably needs to be put back into the activation form for it to work.

    Especially when you try to incorporate it by jiggy riggin
    it to the upgrade-schema.php>

    add_option('active_plugins');

    the code obviously goes before the last )
    and a comma should seperate the setting vs the action.

    Such as:

    add_option('active_plugins',
    a:21:{i:0;s:16:"plugin1.php";i:1;s:32:
    "plugin2.php";i:2;s:11:"plugin3.php";i:3;s:13:
    "plugin4.php";i:4;s:22:"plugin5.php";i:5;s:14:
    "plugin6.php";i:6;s:20:"plugin7.php";i:7;s:13:
    "plugin8.php";i:8;s:13:"plugin9.php";i:9;s:12:
    "plugin10.php";i:10;s:14:"plugin11.php";i:11;s:19:
    "plugin12.php";i:12;s:20:"plugin13.php";i:13;s:9:
    "plugin14.php";i:14;s:23:"plugin15.php";i:15;s:11:
    "plugin16.php";i:16;s:16:"plugin17.php";i:17;s:14:
    "plugin18.php";i:18;s:26:"plugin19.php";i:19;s:12:
    "plugin20.php";i:20;s:15:"plugin21.php"');

    Now obviously this wont work, but the question is why?
    What is the argument parameter to make this code add itself
    to the active_plugins list?

    I realize that if I ever change any plugins that I would need to find this entire code again in the sql database user files. Thats fine, but for right now I am trying to
    find a simple way to auto activate the plugins for users
    without having to go through each and everyone manually.

    This seems like the easiest way of doing it, without
    creating a whole new php script code. Which if anyone has
    one, I'll be happy to buM it off of you and give proper credit. But, typically I would like to make sure that the wp backend plugin menus are not viewable for any non site admin, especially not to regular blog admins, because I dont want them messing with it.

    Obviously I want all plugins, except backup.php active, so I'm not worried about this route.

    However, if someone has an easier way or a safer way that
    will not cause major crashes/corruption to the server/wpmu then of course I'm all ears.

    But, since NOBODY on this forum has mentioned anything like this, I have to assume this is new territory.

    Does anyone know the proper command to input into the schema that will make the active_plugins list code auto activate upon newly created mu blogs?

    If not thats fine, I will continue to attempt to hack it till I figure it out, but I would rather save myself a few weeks worth of work for something easier or from someone that actually knows what this code means.

    There are other pieces of the code that could be useful in the script for auto activation.
    Such as:

    activate_plugin
    $plugin
    $current_plugins
    get_settings
    wp-content/plugins/

    So, I will play with those pieces of the code as well to find a simple solution, although I prefer a pre-existing built php code that can already work as a plugin.

    Any help in this matter is truly appreciated.

    I prefer serious suggestions, code cures.
    I could care less for people with only half a brain.

    JustMSW

  3. mrjcleaver
    Member
    Posted 17 years ago #

    What a fabulously long (yet somewhat windy...) post!

    I ought say that I had tried this plugin but gave up, for similar reasons.

  4. andrea_r
    Moderator
    Posted 17 years ago #

    "However, let me say, who in their right mind did not incorporate the auto plugin activation for new plugins?"

    Maybe I'm overlooking something, or maybe you are, but have you checked out the mu-plugins folder?

    Plugins dropped into that folder *are automagically activated*.

    " Because, if we do, then the user that created the new blog in the wpmu will have to either activate the plugins themselves or rely on a site admin to do it for them.

    How ridiculous is that! Talk about security risks out the flippin wazzoo! "

    Ummmm...... the reason there's a plugins menu where users can activate or deactive plugins at will is so they have a *choice* as to which plugins they want to use.

    How is it a security risk? Users can't do anything other than turn optional plugins on or off. Plugins that I would hope you've tested for vulnerabilities beforehand. (And really, many of the plugins you'd want either add things to the admin backend, leaving no room for error on the part of the user - at least in activation, or they allow to user to add things to posts.)

    "I know the MU Plugin Management (plugman) does very well for global purposes. But lets imagine you had to globally activate 100 blogs for that day manually. Now you think this is a simple process... But, oh wait... how much resource would it take to globally activate and continue to reactive all blogs for plugins to take affect."

    Well first - why on earth would you manually activate as many as 100 blogs? *scratches head* Secondly, in most cases with most plugins, activating it only makes it accessable to be run. Can't see how it would be a resource drain anymore than activating a blog is. You do know that Wordpress.com is run off MU? And that the deveolpers behind that are on this project as well? (albeit MU is a bit behind...)

    "However, most web hosts are so dang cheap that its not possible for some server hosts to allow you access to edit the sql database itself."

    Huh? I've been on plenty hosts and if they're letting you have a database, but not letting you access it, then FIND ANOTHER HOST. That's all kinds of wrong.

    Really, have you even used Wordpress before? From the long-windedness of your post I'm afraid you're making it very, very complicated. Way more complicated that it actually *is*.

    The Plugin Manager plugin is not very useful for a lot of MU hosts, It was only meant as a way to allow certain users (for example PAID) to have access to more complicated plugins or ones with more features.

    Honestly, you'd have far more responses and help if you asked a specific questions as to what you're trying to do, rather than tell us all how you think it should be done and where development went wrong. Really, for someone who professes not to be a coder, you sure have a good idea as to how it should be done.

    "I noticed back at the author's site that someone stated they figured out how to make it "automatically activate" all plugins for new users (some option that you can turn on or off)."

    Looking at the link you posted, it was the plugin author. Have you tried contacting them with your question, rather than trying to rip forum volunteers a new one?

  5. justmsw
    Member
    Posted 17 years ago #

    I agree with you in many regards,
    however the MU that I am trying to setup will allow for a large community based, more than 100 blog is not unrealistic.

    Infact, I plan on at least 1000 blogs per community wpmu.

    I believe that it should work, although I am sure there will be problems such as this one that we are discussing.

    I do not believe that the plugman plugin has much to do with what I am trying, I think it was just that someone thought up the code on the side to auto activate plugins on newly created blogs. Meaning that the plugman plugin does not hinder and from looking at the code, does not offer what is necessary to preform this action, however, I will speak with the author to see if he has any insight, although it looks like that he stopped working on it, quite some time ago, which I am noticing about most plugins for wordpress these days.

    As for the difference between mu-plugins and plugins folders, yes I forgot to mention that... I have already tried that. Most of the plugins that I use which is about 21 different working plugins are functioning only within the plugins folder, they all error in the mu-plugins folder, only because they were not designed to work in the mu-folder. I understand that they will autoactivate while in the mu-folder and I understand that they will not be visible in the plugins menu once they are activated in the plugins folder. But, none of the plugins that I am using work in the mu-plugins folder. They just give database errors all across the page.

    The security risk of allowing other users activating or deactivating their own plugins could hinder their own blog in the wpmu. Although siteadmin could fix most issues, the security issue arises when a user decides they dont want certain plugins active, yet they may be necessary for the function of their own seperate blog and could possibly lead to a major corruption of their own blog, which could hinder the performance of the entire wpmu.

    Basically in design, I am creating a linkable blog community, which I have everything designed perfectly, except for the missing key: auto activation of plugins per new blogs.

    I am still working at it, although I have tested it 40 times so far and created many multiple accounts per the schema file, I have still yet to come with results, although I feel sometimes Im getting two steps closer, then there are other times that I am getting 10 steps back.

    As for knowing about the code, I quickly grew a grasp to it rather quickly. :-)

    If anyone has any other suggestions please throw them at me, I will continue to work on it for the rest of the week.

    JustMSW

  6. treepour
    Member
    Posted 17 years ago #

    JustMSW, you're my new hero. I've been beating my head against the wall all day over precisely these problems, and all of the suggested "simple" solutions fail for exactly the reasons you've articulated.

  7. buzink
    Member
    Posted 16 years ago #

    I do the following to auto-activate a plugin:

    $ekoplan_plugins = array('wikimap/WikiMap.php');
    update_option('active_plugins', $ekoplan_plugins);
    wm_install();

    in the function "install_blog" in the file "wpmu-functions.php".

    "wikimap/WikiMap.php" is the plugin file. "wm_install" is the installation function of the plugin (wikimap in this example). find the name of this function by searching for "add_action('activate" in the plugin file.

  8. nolageek
    Member
    Posted 16 years ago #

    It'd be nice if we could specify what plugins were available in user's Plugins menu. For instance, I can't let them have access to the plugins folder at all, because I dont want them to have access to one of my plugins - therefore I have to manually activate plugins for everyone.

  9. lunabyte
    Member
    Posted 16 years ago #

    "I can't let them have access to the plugins folder at all, because I dont want them to have access to one of my plugins"

    You need my Main-site only hack for plugins.

  10. drmike
    Member
    Posted 16 years ago #

    Either that or place it in mu-plugins and keep quiet about it. :)

  11. mysorehead
    Member
    Posted 16 years ago #

    If the lines in wp-settings:

    if ( !defined('PLUGINDIR') )
    define('PLUGINDIR', 'wp-content/plugins'); // no leading slash, no trailing slash

    were moved to just above where they seem to be needed:
    if ( get_option('active_plugins') ) {

    then the mu-plugins are loaded before the PLUGINDIR constant is set (and first used) could be easily set by a mu-pluglin.

    This would also be useful for those after plugins for premium users or different groups of users with various different plugin folders being used. Maybe using $blog_id

    Richard

  12. mysorehead
    Member
    Posted 16 years ago #

    Still thinking about this...
    You could also make your own plugin page (as a mu plugin) and display it. Using the code found in the plugin page but filter the results before displaying them. Easy

  13. nolageek
    Member
    Posted 16 years ago #

    drmike> Either that or place it in mu-plugins and keep quiet about it. :)

    I thought about that, but it shows in the Options menu. The one in particular I can think of is Random Title. I'm using it on the main blog and I'd like to use it on one other blog - but if I activate the plugins menu then who knows how many users will activate it and mess around with the options and complain that it's not working. (It requires a theme hack.)

    There's a few plugins that I'd like to offer as 'premium' but I can't put them in the mu-plugins everyone will then have access to them.

    Just something to think about. :)

    lunabyte> You need my Main-site only hack for plugins.

    I actually use it! :) Love it. but I have plugins that I'm using for 'special' blogs that I dont want other users to have. (Premium members, I guess.)

  14. Ovidiu
    Member
    Posted 16 years ago #

    if I remember right, lunabytes main-site only hack has a line with something like: if site = 1 just modify that manually to if site == 1 | 2 | 18 for whatever blogs_id you want to activate those plugins... works for me as I have 2 blogs I take care of on my wpmu install

  15. ketose38
    Member
    Posted 16 years ago #

    I want also to activate plugins while generate a new blog automatically.
    Is there any fix out yet?

    greetings from germay
    ketose

  16. drmike
    Member
    Posted 16 years ago #

    Have you read the thread that you just posted into?

  17. hardy101
    Member
    Posted 16 years ago #

    buzink's post above works. But I changed it a little. My plugin is automatically activated when I add the following code to the install_blog() function within "wpmu-functions.php"

    $auto_plugin = array('advanced-admin-menus/aamenus.php');
    update_option('active_plugins', $auto_plugin);
    do_action('activate_' . $auto_plugin);

    Done!

  18. shanepearlman
    Member
    Posted 15 years ago #

    Almost there - but I am totally stuck on the final step.

    I have been able to get the plugin to activate, but my code is not running the install function and hence the database tables are not being built. I'll admit that I am pretty much groaping in the dark here. I was hoping just dropping the plugin in mu-plugins would do the trick but no cigar.

    Two main questions:

    1) How do I even know if the em_install() function is getting called since no output shows from a blog creation. This is hard to debug.

    2) How do I get a file to run and a function to get called (since that seems to be the problem). If it isn't, I am baffled. See details below.

    I have tried a number of variations:

    The simplest (based upon buzink's and hardy101's):

    $auto_plugin = array('EventManager/EventManager.php');
    update_option('active_plugins', $auto_plugin);
    em_install();

    but no luck there

    tried replacing em_install(); with

    do_action('activate_' . $auto_plugin);

    and then

    do_action('activate_EventManager/EventManager.php');

    and then

    do_action('activate_em_install();');

    function still does not seem to run.

    The file referenced basically calls the install and hooks code (EventManager.php):

    define("EM_URL", get_settings('siteurl') . "/wp-admin/admin.php?page=EventManager/");
    define("EM_BASE_URL", get_settings('siteurl') . "/wp-content/plugins/EventManager/");

    $em_event_table = $table_prefix . "em_event";
    $em_registration_table = $table_prefix . "em_registration";
    $em_question_table = $table_prefix . "em_question";
    $em_answer_table = $table_prefix . "em_answer";

    require_once(ABSPATH . "wp-content/plugins/EventManager/includes/install.php");
    require_once(ABSPATH . "wp-content/plugins/EventManager/includes/em-functions.php");
    require_once(ABSPATH . "wp-content/plugins/EventManager/includes/em-hooks.php");

    The Install.php file contains and then adds a hook for em_install():

    install is long so I will not include it.
    add_action("activate_EventManager/EventManager.php", "em_install");

    Any advice would be wonderful. This is basically one of two final bugs and the project is done.

  19. MazZziKa
    Member
    Posted 15 years ago #

    command manager

  20. MrBrian
    Member
    Posted 15 years ago #

    MazZziKa: It's called Plugin Commander. At least get the name right if you're going to recommend a plugin in two words. This thread is a month old too, it didn't need your reply.

  21. bbrey
    Member
    Posted 15 years ago #

    Anyone ever figure out how to autoactive a plugin that won't work in the MU-Plugins folder and that requires database entries to be added? i.e. nextgen gallery

    Cheers!

    Brian

  22. andrea_r
    Moderator
    Posted 15 years ago #

    Use the plugin commander plugin. :)

  23. bbrey
    Member
    Posted 15 years ago #

    I didn't have any luck with the plugin commander.:( The gallery tab shows up for the users, but the only options available are upgrade and uninstall. It appears that the database tables aren't being created, unless the plugin is manually activated.

    I'm not skilled enough to figure it out, but I'm thinking maybe adding the database creation script for NextGen into the wpmu-functions.php file, that way the tables are created when a new users signs up.. what are your thoughts?

    Brian

  24. MrBrian
    Member
    Posted 15 years ago #

    My thoughts are the plugin needs to be made compatible with wpmu, like many plugins. Nothin simple is gonna fix it.

  25. andrea_r
    Moderator
    Posted 15 years ago #

    It's been a while since I tried Nextgen, actually. and it was *supposed* to work with MU.

    Is there really anything that fabulous as a must-have with it, (outside of the lightboxes and flash, which I don't care for) that you can't get with the now default gallery tags?

  26. trcwest
    Member
    Posted 15 years ago #

    has any one had the problem with the plugins updater...

    as when i log in a fresh on a new computer it tells me about the pugins that need updating theni click update then once one updates i loose the option to update the others but the plugins tab has a red note indicating that there are plugins that need to be updated??

    Any thoughts people

About this Topic