Unhook the_content filter during megamenu building.

Posted in: Newspaper
Post count: 1

Hi there,

I am trying to resolve an issue with a membership plugin (Paid Memberships Pro) we use for our news site.

The membership plugin filters content during “the_content” filter in order to hide content to non members. However there seems to be an issue with the page based mega menu that uses the_content filter to render shortcodes etc. The menu can get filtered when it is shown on or near membership content (the_content doesnt have any identifying features e.g. page ID).

I have reached out to the membership plugin developer and they have been trying to work on compatibility with your theme — they are asking for a hook they could use, so they can unhook their filter during megamenu rendering, and then rehook once it is complete.

Here is there message to me:-

“I managed to replicate this issue with both the category and page ID method for mega menus. The code you shared definitely helps us, however it seems there’s no easy hook to disable the_content while in the menu item or location by the looks of it.

To help speed up support, please can you reach out to the Newspaper support team to provide us with hooks to unhook the_content temporarily while in the header menu item. I wasn’t able to find the right hook within their plugin or theme, but I am still going to look into this further.

The idea to the solution would be to unhook the_content while in the menu location and add it back once the menu is finished rendering which should help.

Thank you for your patience and understanding.”

I can find the problem line on Line 205 /td-composer/legacy/common/wp_booster/td_menu.php

Is this something you would kindly help with?

Kind Regards
Jeremy Stone

Post count: 35449

Hi,
If what is need to to unhook the code from line 205 on /td-composer/legacy/common/wp_booster/td_menu.php when it can be done using the remove_filter('the_content', '$content'); I think that a function similar with this one can be used – https://pastebin.com/mj2fzL6z
Now the code needs to be adjusted and a developer can do it and set the right priorities to get the correct results.
This code can be added in functions.php in a child theme or integrate in a plugin.
I hope this will help you!
Thank you!

Viewing 2 posts - 1 through 2 (of 2 total)
The forum ‘Newspaper’ is closed to new topics and replies.