Questions tagged [wordpress-action]

19 questions
2
votes
0 answers

Add action to wp_head from a callback render gutenberg function

I developed a custom slider block, and i'd like to add an action to the wp_head in the callback render function. Obviously it's not working using add_action('wp_head', .... ) because the render callback function is called after the wp_head hook is…
2
votes
0 answers

how to show calculated value in backend on woocommerce checkout page

I'm creating an online store for my company which is a subsidiary of a bank. With the help of banking loan we want to build the infrastructure of selling goods via installment. By using this plugin I managed to add a select field which let the buyer…
2
votes
0 answers

WP Gutenberg block callback - How to add dynamic css (to head)?

I've made a custom block that would require some custom css. I can't do this inline as an attribute to the element since it has some conditional @media stuff in it. I thought of using the actions wp_enqueue_scripts or wp_head. This is the simplified…
1
vote
1 answer

I'm trying to have a popup appear when a customer suspends their account (WooCommerce subscriptions)

The the only action I got to somewhat work was this one, but this shows the popup when the "suspend/hold" button is on the page, not when it's pressed. I want the popup to appear when it's pressed, I've tried the ones mentioned in the documentation,…
1
vote
1 answer

WooCommerce hook on order status change fires multiple times instead for only the changed order

I've created a hook for WooCommerce when an order is cancelled like so: add_action( 'woocommerce_order_status_cancelled', 'prefix_order_cancelled_hook' ); function prefix_order_cancelled_hook($order_id){ write_log("Order ${order_id} has been…
0
votes
0 answers

How do I track WordPress Ajax form when an ajaxComplete event is fired in Google Tag Manager?

Problem: Custom GTM javascript variables are becoming empty. Details: I have configured Ajax Event Listener tag in Google Tag Manager which fires an event called “ajaxComplete”. I have also created variables to collect user data. Then I have…
0
votes
0 answers

Wordpress admin post multiple filters not working individually

I've created custom post named talent, and created 3 admin filters based on custom fields, i.e., gender, travels from and vaccination. Here is the code: add_action('pre_get_posts','talent_filter'); function talent_filter($query) { if ( !…
0
votes
0 answers

What is a good action to use to update the WP database from my plugin?

I need a good trigger to use in my plugin to kick off changes to the website. I've got a custom plugin that goes on all WordPress sites that I build. I've got it set up to auto-update the plugin. Occasionally, I need to push out an update across all…
0
votes
1 answer

Call to undefined function wp_should_load_separate_core_block_assets() wordpress

I'm a newbie in WordPress, have one issue in my implementation as below, P.S. Error occurs only on the server(cloudways), not in the local environment, and even on the server, it occurs after certain hours not continuously. PHP Fatal error: …
0
votes
1 answer

add_filter is running before add_action In Wordpress

Actually I am trying to add some actions add_action and add_filter. But I don't know why add_filter is running before add_action. As I have set the same priority & I read in Wordpress documentation that if actions have same priority then the action…
Aman Sharma
  • 153
  • 1
  • 4
  • 12
0
votes
1 answer

WordPress: do_action won't work in ajax callback function

I want to perform some actions when ajax tasks done successfully. For instance, if the item added to the cart, I want to send an email. Also may perform a few more actions. Setting up do_action('prefix_item_added_to_cart', $args); doesn't recognized…
Code Lover
  • 8,099
  • 20
  • 84
  • 154
0
votes
3 answers

Wordpress action "wp": Cannot modify header information

I would want to show some HTML code in my WordPress page. So in my child theme functions.php, I have written an action like this one: add_action('wp', function() { if(is_admin()) { return; } $html = '
JarsOfJam-Scheduler
  • 2,809
  • 3
  • 31
  • 70
0
votes
1 answer

WordPress: how to get the full path on 'init' hook? or is it another hook preferable?

I would like to redirect users if they are not administrators, and I do within an add_action('init'... function However, I would like NOT to redirect users if the URL path is something like /wp-json(v1/... (so not a user but a custom REST API…
GWorking
  • 4,011
  • 10
  • 49
  • 90
0
votes
1 answer

WP Assign Attached Image to Category

Managed to display images attached to a specific category independently of it's parent's category. Now wanting newly uploaded images to be dynamically assigned to a category. In mySQL can manually do this with: INSERT INTO `wp_term_relationships`…
Josh Lewis
  • 125
  • 1
  • 2
  • 9
0
votes
2 answers

How I can get WooCommerce Checkout Registration variables?

WooCommerce shop. Setting "Customer can register while checkout" is ON, so customer have to fill his Name, Phone and Email while checkout (on /checkout/ page). I want to check this data for errors before registration. So, I try to get this data…
1
2