The MU forums have moved to WordPress.org

Making Plugins work on MU (19 posts)

  1. vezhead
    Member
    Posted 14 years ago #

    Whats the main difference between MU plugins and regular WP plugins? For example, I have a plugin I want to be able to use in the mu-plugins folder but it doesn't auto activate. Is it possible to modify that plugin so it auto activates in the mu-plugins folder?

  2. freshestnoob
    Member
    Posted 14 years ago #

    Theoretically, normal wp plugins should work with mu.

    Practically, most dont work. You will have to hack some. Mu specific plugins are available at wpmudev.

  3. vezhead
    Member
    Posted 14 years ago #

    So whats the difference between them? Is there code you need to add to a plugin to get it to work on MU? I'm sure its not that simple but I just don't get why some work and some don't.

  4. lunabyte
    Member
    Posted 14 years ago #

    Mu-plugins is a special, exclusive directory where any file located within it's top level is included on every single page load, and should be used with extreme caution.

    If you have say, 100 blogs, and less than 80% of the blogs would even think about using something, don't use MU plugins. Honestly, if it isn't something that more than that (say 95-100%) use, I'd leave it in /plugins/ and let the user decide.

    Mu-plugins can be a good thing, when used sparingly, but overall if it absolutely doesn't have to be there, do put it there.

  5. andrea_r
    Moderator
    Posted 14 years ago #

    plugins don't auto-activate in the mu-plugins folder. They auto-execute. yeah, there's a difference. As for the plugin, it's a big fat "it depends". Mostly on how it is coded, what the plugin does and how it accesses the db, if at all. Not every plugin developer is the best out there or follows the same standards. There is no hard and fast thing to get all plugins working there all the time.

    It's better off to specifically state the plugin you're having issues with. Someone may have fixed it or there may be an alternative.

  6. vezhead
    Member
    Posted 14 years ago #

    The plugin that I want to autoexecute is WP User Manager, it lets me add fields to the users profiles. I'd like this plugin to autoexecute so users can fill in the extra profile fields when they first sign up. Has anybody got this working for the mu-plugins folder?

    I'd even be willing to pay someone to do it if they thought it was possible...

  7. vezhead
    Member
    Posted 14 years ago #

    $30 to anyone who can make the WP User Manager plugin autoexecute in the mu-plugins folder... :)

  8. MrBrian
    Member
    Posted 14 years ago #

    Just putting it in the mu-plugins folder DOES make it autoexecute. I took a quick look at the code and i'm thinking the hooks just need to be changed. Try these changes, but I can't guarantee it will work perfectly without testing obviously.

    IN wp-user-manager.php:
    -On line 105: change "register_form" to "signup_hidden_fields"
    -On line 111: change "user_register" to "signup_extra_fields"

    then the changing the post verification is a little tricky, do this:
    -On line 108: change "add_action" into "add_filter". then change "register_post" into "wpmu_validate_user_signup"
    -Go down to line 362 and instead of "registrationCheck()", make it "registrationCheck($errors)".
    -Delete the next line (363).
    -On line 369, change "$errors[$key]" into " $errors['errors']".

    Let me know what happens. If you are not used to editing code like this, i highly recommend not using WPMU.

  9. vezhead
    Member
    Posted 14 years ago #

    Hey MrBrian,

    I made those changes you mentioned but it doesn't appear to quite be working. I don't get any error messages but the plugin menu doesn't show up as it would if I manually activated the plugin. I appreciate you checking it out for me. Any other ideas?

  10. MrBrian
    Member
    Posted 14 years ago #

    Make sure the files are not in a subdirectory inside of mu-plugins. I'm pretty sure the mu-plugins folder does not recursively autoexecute files in directories under it, only the files in the root of the folder. Also be aware that when the plugin is working, regular user's might be able to access menus that you don't want them to access because of the way WPMU is fundamentally different. For example, in regular wordpress, you would assume the blog administrator is the highest level person, but with WPMU the highest level is the SITE administrator. Therefore, such plugins where you do not want all your bloggers to have access to the plugin's menu will need to have their menu functions modified.

    Regards,

    Brian

  11. vezhead
    Member
    Posted 14 years ago #

    Thanks Brian. I think that is getting me on the right track. I did receive these 2 errors that are preventing it form working. I've made other changes to the code so the lines won't quite match up so I included the line of code.

    wp-signup.php page error:
    Warning: Invalid argument supplied for foreach() in /wp-content/mu-plugins/wp-user-manager.php on line 458
    my line 458: foreach($this->extraFields as $key => $extraField) {

    usser profile page error:
    Warning: Invalid argument supplied for foreach() in /wp-content/mu-plugins/wp-user-manager.php on line 291
    my line 291: foreach($this->extraFields as $key => $extraField) {

  12. vezhead
    Member
    Posted 14 years ago #

    Sorry...the first error is actually on the page that gives you your password after you've clicked through the email to activate

  13. MrBrian
    Member
    Posted 14 years ago #

    Looks like one of the action hooks was fine, i made you change it on accident :).

    Back on line 111 which now says "signup_extra_fields", change it back to user_register.

    Also, now that i look at the code better, depending on where you want the extra fields to show up you have to use different hooks for the formFields. I would think you want the extra fields to display below the blog form, right? Right now it will display above it which i think would look awkward, so search the file for "signup_hidden_fields" and change to "signup_extra_fields".

    Sorry this is a bit messy. Now you see the differences of WPMU :). The signup process is very different, but they share similar functions. Normal wordpress doesn't even have a wp-signup.php. Once again, i haven't tested any of this. It's all speculative from looking at the code.

  14. vezhead
    Member
    Posted 14 years ago #

    lol..well here we go:

    on wp-signup.php
    Warning: Invalid argument supplied for foreach() in /wp-content/mu-plugins/wp-user-manager.php on line 253

    this is on wp-signup.php after you press the submit button for "gimme a listing"

    Warning: Invalid argument supplied for foreach() in /wp-content/mu-plugins/wp-user-manager.php on line 365

    Warning: extract() [function.extract]: First argument should be an array in /wp-signup.php on line 287

    Fatal error: Call to a member function get_error_code() on a non-object in /wp-signup.php on line 289

  15. vezhead
    Member
    Posted 14 years ago #

    had a question about putting the files straight into the mu-plugins folder too. If I put ALL the files in that folder, the Add Field form shows up on the signup page. Do I need to put all the files in the mu-plugins folder or just the wp-user-manager.php file and then the rest in a folder in the mu-plugins folder?

  16. zappoman
    Member
    Posted 14 years ago #

    Like Lunabyte said:

    Mu-plugins is a special, exclusive directory where any file located within it's top level is included on every single page load, and should be used with extreme caution.

    any php file in mu-plugins will get included on all pages...

    mu-plugins isn't exactly like plugins.

  17. MrBrian
    Member
    Posted 14 years ago #

    Ah i see the problem. Make line 369 this instead:

    $errors['errors']->add($key, $lerror);

  18. zappoman
    Member
    Posted 14 years ago #

    btw, if you want to take wordpress plugins that are designed to live in subdirectory folders where some of the files get loaded automatically (because they have a plugin name) and others are only loaded when neeeded...

    Then you might want to check out the following wordpresmu "plugin" that I built last year...

    http://heftagaub.wordpress.com/2007/04/06/supporting-subdirectory-plugins-in-wordpressmu/

  19. vezhead
    Member
    Posted 14 years ago #

    Hey Brian...made that change but still getting the same errors. Pretty bizarre...

    Thanks for the link zappo

About this Topic