Make WordPress Core

Opened 16 years ago

Closed 16 years ago

Last modified 16 years ago

#16309 closed defect (bug) (invalid)

add_filter('the_content', 'myfunction') doesn't work when multi site.

Reported by: matsubobo Owned by:
Priority: normal Milestone:
Component: Plugins Version: 3.1
Severity: minor Keywords: add_filter
Cc: Focuses:

Description

I wrote simple plugin code to test the issue.

function myfunction($content) {
        $content = 'test'.$content;
        return $content;
}
add_filter('the_content', 'myfunction');

The code works single wordpress and main site when multi site setting. However, child-sites when multi site setting.

WP 3.0 and 3.1 have same issue.

Attachments (1)

addfiltertest.php (360 bytes ) - added by matsubobo 16 years ago.
test code

Download all attachments as: .zip

Change History (7)

#1 @nacin
16 years ago

  • Milestone Awaiting Review
  • Resolutioninvalid
  • Status newclosed

The plugin needs to be network activated, otherwise it isn't included apart from the main site. Plugins are maintained on a per-site basis by default.

For additional help, please try the multisite support forums: http://wordpress.org/support/forum/multisite/.

#2 @matsubobo
16 years ago

I think I understood how plugin is activated on multi site.

I also tried following code to analyze the plugin is activated.

function myfunction($content) {
        print 'this block is passed.';
        $content = 'test'.$content;
        return $content;
}
add_filter('the_content', 'myfunction');

"'this block is passed." was displayed but "test" was not displayed on child-sites.
Both "this block is passed" and "test" where displayed on the main site.

@matsubobo
16 years ago

test code

#3 @matsubobo
16 years ago

  • Component GeneralPlugins
  • Resolution invalid
  • Status closedreopened

#4 @nacin
16 years ago

  • Resolutioninvalid
  • Status reopenedclosed

You're not activating the plugin on each of the child sites.

The plugin needs to be network activated, otherwise it isn't included apart from the main site. Plugins are maintained on a per-site basis by default.

For additional help, please try the multisite support forums: http://wordpress.org/support/forum/multisite/.

#5 @matsubobo
16 years ago

I found a solution.

Some other plugin removes my original filter so I set high priority.

add_filter('the_content', 'cyta_modify', -10000);

#6 @jorbin
16 years ago

This looks like it might be a duplicate of #15705

Note: See TracTickets for help on using tickets.