thenbrent / multisite-user-management

In a Multisite WordPress, automatically add new users to each of your sites.
http://wordpress.org/extend/plugins/multisite-user-management/
GNU General Public License v2.0
122 stars 30 forks source link

Plugin doesn't load if moved to mu-plugins directory #3

Closed mfoti closed 14 years ago

mfoti commented 14 years ago

I have installed the plugin from wordpress3 installation page, and in wp-options.php page it give me the error that ask me to move it inside the mu-plugins directory, so I create it and move the multisite-user-management directory inside mu-plugins: "wp-content/mu-plugins/multisite-user-management".

Now in wp-options.php there is no error and no options about that plugin.

I use the 0.3 version of the plugin.

thenbrent commented 14 years ago

Hi skler, you only need to move the ms-user-management.php file into the mu-plugins directory.

Unfortunately the mu-plugins directory behaves differently to the standard plugins directory. The php file has to be in the root of it, not in its own directory, or else it is not activated, exactly as you are seeing.

Hope that helps. I'll try to make this more clear in the installation instructions.

berteh commented 14 years ago

Hi thenbrent.

thanks for your useful plugin (works nicely with WP3.0 when uploaded to wp-content/mu-plugins/ms-user-management.php)

Actually the WP 3.0 integrates multi-site from the start (called "network"), so there is no need for mu-plugins directory any longer. Could you therefore please change your code to be installable in wp-content/plugins? this would make installation MUCH easier (eg using plugins admin panel).

thanks.

thenbrent commented 14 years ago

Hi Berteh, I wish there was something I could do, but the multisite registration calls a hook before the standard wp-content/plugins/ directory is loaded, so it has to go in the mu-plugins directory.

I guess it was an oversite in the merge? Or perhaps by design, but regardless, it's outside of the control of a plugin file.

Brent

berteh commented 14 years ago

Hello Brent, You could then maybe call another hook that is well handled by WP?

I guess you talk about that one you use to add the configuration section in the superadmin-options dialog... wp-hashcash does it in such a way that works nicely with WP3 and multisites... i just don't know if it's helpfull:

add_action('admin_menu', 'wphc_add_options_to_admin');

function wphc_add_options_to_admin() {
    if( function_exists( 'is_site_admin' ) && !is_site_admin() )
            return;

    if (function_exists('add_options_page')) {
            if( function_exists( 'is_site_admin' ) ) {
                    add_submenu_page('wpmu-admin.php', __('WordPress Hashcash'), __('WordPress Hashcash'), 'manage_options', 'wphc_admin', 'wphc_admin_options');
            } else {
                    add_options_page('Wordpress Hashcash', 'Wordpress Hashcash', 8, basename(__FILE__), 'wphc_admin_options');
            }
    }
}
thenbrent commented 14 years ago

Hi Berteh, It's actually the wpmu_activate_user hook, called when a user registers. It's no problem to add the admin page, but without being the wpmu folder I can not run any code when a user activates their account. Off the top of my head, I can think of other ways around it, but they'd be inefficient - like everytime a user logs in, making sure they have the relevant roles for each site.

I did look original at a way to get it into the wp-content/plugins/ folder, but I'll have a look sometime and see if there is a bearably inefficient way to get around using the wpmu_activate_user hook.

Brent

berteh commented 14 years ago

thanks for taking the time to explain.

Would the hook user_register be an acceptable alternative? (you might need to check if you are in multisite settings... but I guess no one would install your plugin in a single blog setting anyway.)

moreover at http://adambrown.info/p/wp_hooks/hook/user_register

Berteh.

thenbrent commented 14 years ago

Just having a look at it now Berteh. I'll let you know soon. :)

thenbrent commented 14 years ago

Berteh, same problem. Any code in the wp-content/plugins/ folder is loaded only after the user is registered. So although the 'user_register' hook is called when a user activates their account, if the plugin is not in the mu-plugins folder, then it is not loaded and therefore, no functions in it are called. So the problem isn't the hook at this stage, it's the architecture of WP Multisite's activation which doesn't load plugins in the plugins directory when a new user registers.

As I said before, there are other ways to have the plugin operate in the plugins folder. I have looked into at least one of these that might be suitable. Just short on time for putting it into code!