Searching a hook which triggers when deleting a post to get all comments

There are few other hooks to manipulated the trashed comment. ‘save_post’: called after post is saved. You can check status of the post and manipulate its comment accordingly. ‘trashed_comment’: called after comment is moved to trash status. ‘transition_comment_status’: called whenever comment status is changed. There are probably few others too. But, it depends what you … Read more

Hooking after get_header()

I hate answering questions in the negative because it is easy to go wrong, but there is no core hook that does that– at least no hook that I have ever seen. I admit it could be handy for a couple of things though. wp_header() loads the theme’s header file. That is about it. It … Read more

Set template based on query in URL

There are a number of template filters available to override template selection. For a single post you can use the single_template filter: function wpa_single_template( $template ) { if( isset( $_GET[‘template’] ) ) { $template = locate_template( $_GET[‘template’] . ‘.php’, false ); } return $template; } add_filter( ‘single_template’, ‘wpa_single_template’ );

Conditionally call add_action depending on post_type?

Using OOP PHP, add your initializer actions in the __construct and create appropriate methods for handling them. From your handler you can initialize any class variable (once) you want and reference it later without having to do any further checks. Here is an example: class my_plugin { private $post_type; private $isCustom = false; public function … Read more

WooCommerce New customer email Hook? [closed]

There is no actions/filters to hook to. You need to override standard WC_Email_Customer_New_Account class and implement your own logic. To do it you need to create your own class which will inherit that class and register it. class WPSE8170_Email_Customer_New_Account extends WC_Email_Customer_New_Account { function trigger( $user_id, $user_pass=””, $password_generated = false ) { // do what you … Read more

What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?

You will want to use the post_row_actions filter https://developer.wordpress.org/reference/hooks/post_row_actions-2/ For example, to add a link, you could try something like: function add_custom_link($actions, $page_object) { $actions[‘custom_link’] = ‘<a href=”http://www.example.com”>My Custom Link</a>’; return $actions; } add_filter(‘post_row_actions’, ‘add_custom_link’, 10, 2);

How to send an automated user ‘inactivity’ email?

There are three main parts to your question: Log the user last login time Schedule a cron event Send email if contributors and authors haven’t logged in within 20 days The first step is adding user meta to track the last login. WordPress does not track the last time a user logs in, so we’re … Read more

On WordPress 4.4, how to get the post id using the comment_post hook

The third parameter, $commentdata can be used to get the ID for the post that the comment was made on: function wpse211367_comment( $comment_ID, $comment_approved, $commentdata ) { // The id for the post that the comment is related to is available // in the $commentdata array: $comment_post_id = $commentdata[‘comment_post_ID’]; } add_action( ‘comment_post’, ‘wpse211367_comment’, 10, 3 … Read more