How to execute a hook asynchronously?

Yes, that’s what the WP Cron system does. It will fire an action/hook as close to a requested time as it can, and can do it once or multiple times. You would still have a hook that runs on profile_update but it wouldn’t send data to google spreadsheets, rather it would schedule a cron job … Read more

Hook for inserting?

If you have access to the database, you could potentially create a trigger for that plugin-specific table. This bypasses the need for a hook. Depending on how they handle database schema updates, it might even stick around after a plugin update. I’ve never tried triggers on WP tables though, so take this with a grain … Read more

How to access deleted term inside delete_product_cat action

You get 500 error, because you’ve added your filter incorrectly… It takes 4 params, but you register it as it was using only one. add_action(‘delete_product_cat’, ‘sync_cat_delete’, 10, 1); // 10 is priority, 1 is number of params to take function sync_cat_delete($term, $tt_id, $deleted_term, $object_ids){ var_dump($deleted_term); } So if you change that 1 to 4, it … Read more

Restrict access to admin-post.php

I don’t think that disabling admin-post.php is a good idea. Such solution may break WP, some plugins and themes. But there is another, much simpler solution. Just add your action for admin_post (without nopriv) and process it properly – so if it’s a login action and user is already logged in, redirect him to proper … Read more

How to perform action when plugin/theme editor is used?

The ajax action that runs on theme or plugin update is edit-theme-plugin-file so you should be able to hook into it by running code on the wp_ajax_edit-theme-plugin-file hook. add_action(‘wp_ajax_edit-theme-plugin-file’, ‘log_cowboy_coders’); function log_cowboy_coders() { $user = get_current_user_id(); if (!empty($__POST[‘theme’])) { // Log that someone is editing a theme } else if (!empty($__POST[‘plugin’])) { //log that someone … Read more

Assigning alternate single-{cpt} template based on blog_id in multisite

Actually, I noticed that your closure is not capturing/using the proper $template variable which is passed from the template_include filter hook: // This hook is defined in wp-includes/template-loader.php $template = apply_filters( ‘template_include’, $template ) The closure is also not returning the template.. So your closure should look like: add_filter( ‘template_include’, function( $template ) use ( … Read more