Make WordPress Core

Opened 14 years ago

Closed 14 years ago

Last modified 14 years ago

#16309 closed defect (bug) (invalid)

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

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

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 14 years ago.
test code

Download all attachments as: .zip

Change History (7)

#1 @nacin
14 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

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
14 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
14 years ago

test code

#3 @matsubobo
14 years ago

  • Component changed from General to Plugins
  • Resolution invalid deleted
  • Status changed from closed to reopened

#4 @nacin
14 years ago

  • Resolution set to invalid
  • Status changed from reopened to closed

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
14 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
14 years ago

This looks like it might be a duplicate of #15705

Note: See TracTickets for help on using tickets.