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 … Read more

How does do_action( ) works actually?

wpas_after_ticket_submit is the hook name, not the function name. Functions are hooked to it with add_action() by setting the first argument of add_action() to wpas_after_ticket_submit, and the function name as the second argument: add_action( ‘wpas_after_ticket_submit’, ‘function_to_hook’ ); So you need to find a use of add_action() where the first argument is wpas_after_ticket_submit. The 2nd argument … Read more

WooCommerce Hook: Content get’s displayed twice and not AFTER the order total

In case it helps anyone, the do_action(‘woocommerce_review_order_after_order_total’) is called in the middle of a table in the template and expects a table row to be echoed by the add_action hook. If you just echo text or, as in the question, an input, it falls outside the table, appears before not after the table and presumably … Read more

Using delete_attachment to prevent an attachment not working

Updated answer for WordPress 5.5.0+ As of 5.5.0, a new filter has been added to wp_delete_attachment: /** * Filters whether an attachment deletion should take place. * * @since 5.5.0 * * @param bool|null $delete Whether to go forward with deletion. * @param WP_Post $post Post object. * @param bool $force_delete Whether to bypass the … Read more

How to hook code in ?

The action you are looking for is wp_body_open(). I do not know if you are writing your own theme or not but if you are using a pre-built theme, the author of your theme may not have included this support. If properly supported in your theme, any function hooked to this action will be called … Read more