With what hook can I address all posts from all custom post types when they are published?

What about using save_post or wp_insert_post hook, both have @param     int               $post_ID     Post ID. @param     WP_Post     $post          Post object. @param     bool            $update     Whether this is an existing post being updated or not. as parameters. It is pretty self-explaining that the $update can be used to determine, if it … Read more

In a plugin, why is add_action(‘init’) not executed before the plugin is activated?

WordPress is an application and everything that is run within that application is called by hooks. Then 2 main hook functions are add_action and add_filter, but as you saw, register_activation_hook and register_deactivation_hook are other functions that are used in the context of activation and deactivation. There exist more hook defining functions, like functions that will … Read more

Can i check if user is doing any ajax request?

You’d be better off moving your function that updates the meta to a hook that runs on the front end and during AJAX calls. Then you don’t need to bother about checking if the request is an AJAX request or not. init is a good choice for this: function wpse_297026_update_user_activity() { update_user_meta( get_current_user_id(), ‘last_activity’, time() … Read more

Action ‘save_post’ not working for quick edit

It’s just a guess, since I haven’t tested your code, but… There is a part that looks pretty sketchy for me: All your actions are run only if this condition is true: if(isset($post_type) && $post_type == “listings”){ And where that $post_type variable comes from? $post_type = get_post_type(); So you don’t pass any post_id to that … Read more