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

providing access to post_id or post inside functions.php

When you add an action via add_action(), the variables that are available in the callback function are determined by the specific hook you’re using. The load-post.php hook does not pass any values through to the callback function. However, when adding meta boxes the correct hook to use is add_meta_boxes, and that hook provides 2 values … 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