Delete data from database using row action

The “admin_action_{$_REQUEST[‘action’]}” hook does not pass any arguments. You would need to get the article_id from the $_REQUEST array. There are also a few other concerns such as: You’re not assigning an action when you call wp_create_nonce(). As Mafnah suggets in their ansewr, you should use $wpdb::delete() as a shortcut for using $wpdb::prepare(). Here’s how … Read more

How to find where an action is triggered? [closed]

In WooCommerce (my version v6.1.1) there is a file called /woocommerce/templates/checkout/thankyou.php and in line 79 you have trigger with dynamic payment method name so there is a place when each payment method do their magic <?php do_action( ‘woocommerce_thankyou_’ . $order->get_payment_method(), $order->get_id() ); ?> And answering your questions: The opposite. Where is add_action there is a … Read more

Set Taxonomy based on post status

This is what works with the help of WebElaine above. I had to pass the postID to has_category() and then set variables. function add_categories_automatically($postID) { $p_published = get_post_status($postID) == ‘publish’; $p_draft = get_post_status($postID) == ‘draft’; $p_cat = has_category( ‘billed’, $postID); if ($p_draft == ‘draft’){ $catsID = array(1); //active wp_set_post_categories($postID, $catsID); } if ($p_published == ‘publish’){ … Read more

How to pass multiple parameter in add_action()

If you need to call enqueue_assets at admin_init, then add a new add_action(): add_action( ‘admin_init’, [$this, ‘settings_page_registration’] ); add_action( ‘admin_init’, [$this, ‘enqueue_assets’] ); https://developer.wordpress.org/reference/functions/add_action/ That said, if your assets are JS scripts or CSS, you should consider wp_enqueue_script() & wp_enqueue_scripts https://developer.wordpress.org/reference/functions/wp_enqueue_script https://developer.wordpress.org/reference/hooks/wp_enqueue_scripts/

Using add_action before add_filter on a plugin?

It doesn’t matter the order in which you call add_action() and add_filter(). What matters is the order in which the corresponding do_action() and apply_filters() are called. So, if apply_filters(‘wp_insert_post_data’) is run before do_action(‘save_post’), tough luck. You’ll have to think of another way to achieve the desired result.

Run a plugin just ‘once’ per page reload

Basic idea is to use javascript to make an AJAX call back to the site which in turn save the hit because if you use PHP alone, then hits for cached pages won’t be counted because no PHP is processed at that time. Study the code of WP-Postviews plugin http://lesterchan.net/portfolio/programming/php/#wp-postviews Edit: Hook may be fired … Read more