Removing a Filter

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() {
    remove_filter( 
        'um_profile_tabs', 
        [ $GLOBALS['ultimatemember']->user_posts, 'add_tab' ], 
        100
    );
});

I haven’t tested it, because I really don’t want to install that anywhere, so … good luck. 🙂