The MU forums have moved to WordPress.org

Problem wiritng a site-wide plugin (3 posts)

  1. jephperro
    Member
    Posted 16 years ago #

    Hi,

    I have written my own plugin which I want activated site-wide to all my users' blogs. I am using the admin_footer hook, because I want this plugin to fire each time an admin page displays.

    Here's what I did:

    As the admin user, I activated my plugin site wide. The plugin works for me as admin user.

    Next, I self-registered "UserA" and a new blog was automatically created. However, the plugin is not firing for UserA in the admin menu.

    I have been debugging the code and traced all the way into plugin.php

    do {
        foreach ( (array) current($wp_filter[$tag]) as $the_ )
            if ( !is_null($the_['function']) )
                call_user_func_array($the_['function'], array_slice($args, 0, (int) $the_['accepted_args']));

    My function does not appear in $the_['function'] as UserA, but it does as admin.

    Can anyone explain why this would be happening?

    Here is how I tested and debugged. My plugin looks like this:

    add_action("admin_footer", 'testAdminFooterHook', 5);
    
    function testAdminFooterHook()
    {
    echo "<script language='javascript' >\n";
    echo "alert('test admin_footer hook')";
    echo "</script >\n";
    }

    Have I forgotten to do something? It should be this easy shouldn't it? I want to impose this plugin on all my site's users.

    The strangest part is that if I log in as administrator, and view UserA's blog dashboard, then everything works. It's as if as soon as the admin touches the blog, the plugin is registered.

  2. andrea_r
    Moderator
    Posted 16 years ago #

    What happens if you place the plugin in the mu-plugins folder? (which is where we place code we want to run sitewide all the time).

  3. dsader
    Member
    Posted 16 years ago #

    Add the following to the header comments of the plugin and keep it in the plugins folder.

    Site Wide Only: true

About this Topic

  • Started 16 years ago by jephperro
  • Latest reply from dsader