I'm using 'Simply Show Hooks' plugin to spot various filters on a page.

I'm trying to remove the following filter's function (method): UM_User_posts–>add_tab

Here's my remove_filter code so far:

remove_filter( 'um_profile_tabs', '_____', 100);

How exactly would I include that function (method)?

  • It'a an class instance then either you use remove_all_filters('um_profile_tabs', 100); to remove everything on filter um_profile_tabs. or you loop over all filters of this hook to remove only this one. – mmm Nov 10 '17 at 19:09

When you see a hook callback described as UM_User_posts–>add_tab, you know there must be an UM_User_posts object somewhere. If add_tab() had been called statically, the callback description would be UM_User_posts::add_tab.

Now you need access to the same instance of the UM_User_posts class that the plugin is using. How to get to that instance? That's often not possible, so you have to use an ugly workaround.

In your case however, there is a better way. The one, very important information that I'm missing in your question is: What is the plugin whose callback you want to remove? My guess is you are using the plugin Ultimate Members. :)

Now, when I look at the part where the instance for UM_User_posts is created, I notice two things:

  1. I'm running out of polite words to describe that code. Probably my fault. :) But honestly, I would not run that code in production.

  2. The instance is assigned to an undeclared member user_posts of the class UM_API, and the instance of that class is put into a global variable named $ultimatemember. So the instance you need in order to remove the callback is in $GLOBALS['ultimatemember']->user_posts.

And that leads us to the solution:

add_action( 'plugins_loaded', function() {
        [ $GLOBALS['ultimatemember']->user_posts, 'add_tab' ], 

I haven't tested it, because I really don't want to install that anywhere, so … good luck. :)

  • Thanks. You are correct, I am trying out the Ultimate Members plugin. Are you saying the plugin code isn't good enough for production? I also gave your code a shot, but no success. :( I really appreciate your detailed explanation though! – Richard Nov 10 '17 at 21:00
  • @Richard You have to call your remove_filter() after the plugin has created its own instance. The plugin code in general is violating so many best practices that I wouldn't trust it one bit without reviewing every single line. – fuxia Nov 10 '17 at 21:02
  • Ouch! We were hoping of using it in production. :( How would I call it after the plugin has created its own instance though? – Richard Nov 10 '17 at 21:04
  • @Richard I have modified my code to wait for the plugin load. If that still doesn't work, you have to a. dig into the plugin code for yourself, b. find a better plugin, c. write your own code for the membership functionality you need, or d. ask the plugin author for support. – fuxia Nov 10 '17 at 21:09

You need to know the name of the function that was hooked to the filter via the add_filter() command, as well as the priority at which it was hooked.

So, in your example, let's assume that the add_filter() in question looks like this:

add_filter( 'um_profile_tabs', array( 'UM_User_posts', 'add_tab' ), 100 );

Then your remove_filter() should be:

remove_filter( 'um_profile_tabs', array( 'UM_User_posts', 'add_tab' ), 100 );

You do need to match the priority of the add_filter() call. If there's no priority specified in the add_filter(), then it will default to 10. (remove_filter() likewise defaults to a priority of 10.)


  • Thanks, here's what I'm seeing: filter: um_profile_tabs Priority: 100 UM_User_posts–>add_tab – Richard Nov 10 '17 at 19:21
  • I tried your code example and it did not work, even though the priority matched. – Richard Nov 10 '17 at 19:22
  • There must be an UM_User_posts object. Your code is treating the method as a static method which is clearly not in use here. – fuxia Nov 10 '17 at 20:09
  • @fuxia How would I remove the method then? – Richard Nov 10 '17 at 20:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.