Questions tagged [actions]

A name for an event that is executed at specific points throughout the WordPress core.

Filter by
Sorted by
Tagged with
0
votes
1answer
13 views

Query Nopaging action not having effect

I've got a custom loop function in my child theme, in the templates.php file to loop through specific post types ('listings') and then put it into an array to use into a part of my template. Here's an ...
0
votes
0answers
11 views

WP Customizer - How to change theme mod with live preview? When using `remove_action()`

I've made a theme customizer setting that hides the meta data on a single woocommerce product page. When I save the setting and go out of the customizer I can see the setting takes effect. So that ...
0
votes
0answers
22 views

Run a function when a custom post is update?

There is a custom post type. Each post has a repeater field. When a post is updated, I need to get a value from the repeater field and insert it into a custom table in the WordPress database. To do ...
0
votes
0answers
32 views

Issue passing action class to nested function. Admin Columns

Trying to run the same function for multiple actions. I've got it working for ACF, but the Admin Columns action has a class, and I think that's where I'm struggling, though I'm not sure. //Works: ...
0
votes
1answer
25 views

Two functions with different arguments and add_actions, but identical code

I feel like this is simple. I have two functions that contain identical code, but need to have different add_actions and arguments. There's got to be a way to do this so I'm not copying and pasting ...
0
votes
0answers
9 views

What hook do I need to save a setting?

I've added a new field onto the discussion's section on the /wp-admin/options-discussion.php page that outputs along with this: <?php do_settings_sections('discussion'); ?> How can I hook the ...
0
votes
0answers
9 views

Best way to figure out in code if I am in a new post or exiting post

I am using ACF and and ACFBuilder to create all the fields for my content post. The code that creates the field is hooked to the acf/init action. When I am creating and adding these fields, I need to ...
0
votes
1answer
16 views

Hook to change the site URL

I am working on a WP system that is supposed to be served by multiple domains. For example, foo.example.com and elpmaxe.com point to the same installation. But depending on the URL, the system will ...
0
votes
1answer
23 views

Assign user role by text field in Wordpress (Woocommerce)

I have a virtual store with woocommerce where I use the USER REGISTRATION plugin to register new customers. This plugin allows the creation of custom fields. I created a custom text field called "...
1
vote
0answers
31 views

Shortcodes — Using add_action, add_filter in the shortcode

A client wants the following: User clicks on a specific button which takes them to a partner's site. If this is their first time clicking the link, they need to accept terms and conditions. If they'...
0
votes
1answer
19 views

Is it possible to make get variable out of filter in Class?

I am trying to have a variable out of the filter At the end of there is return apply_filters( 'woocommerce_account_menu_items', $items, $endpoints ); function wc_get_account_menu_items() { $...
0
votes
0answers
14 views

Remove action that incudes external class

I'm attempting to achieve something similar to the following question, but I'm having difficulty attaining the desired result - Remove an action from an external Class The Wordpress theme Neve is ...
0
votes
0answers
7 views

How many times should a block's edit be being called?

It feels like the answer should be once, or maybe once per instance of the block on a post/page. I'm writing a new block, and for debugging purposes, I'm logging the post_id very early in my block's ...
0
votes
0answers
12 views

Run function on Add new post button

I have a php function for populating some fields on the edit post page. I want to run this function when the user clicks the Add New button on posts page. Or maybe create a new button to run my ...
0
votes
1answer
40 views

Does hook have an effect on increasing the page load?

I have a personal website which uses WordPress. for same changes on the theme, I can add manually codes on single.php. Or I can write a hook for it. for example, I want to add content on a specific ...
0
votes
1answer
26 views

Combine one action and one filter

I want to show an error message in Woocommerce checkout page, and remove the order button. I can use one action and one filter: add_action( 'woocommerce_before_checkout_form', 'add_checkout_error', 9 )...
0
votes
1answer
23 views

Use PHP Class in Wordpress functions

I have a class that I want to use in functions.php but I'm not sure the best way to set it up I also want to get WooCommerce's cart array. I currently do not have access to WC() in my class yet. What ...
0
votes
0answers
20 views

Hide products based on user role and category

I'm working with Wordpress and Woocommerce and I'd like to hide all products with a certain category from all users, except users that has a special role. For example, let's say I have a category ...
0
votes
0answers
33 views

How to run an ajax call in elementor editor

I am having a strange issue. I am not able to execute an ajax call while in Elementor edit mode. add_action( 'wp_ajax_slug_configureheader', [ $this, 'rename_configureheader_callback' ] ); add_action( ...
0
votes
0answers
7 views

Customize (or create) the Add new post button

I am writing a plugin and I want to customize the add new post button (or create a new button) so that it can create a new post with some values prefilled based on the url. Is it possible?
1
vote
0answers
24 views

Prefixing plugin hooks (actions/filters) with a wrapper class or functions

I'm developing a rather extensive plugin which has a lot of hooks that are prefixed with the plugin namespace. I have created a wrapper class like the one below but because this plugin is geared ...
0
votes
1answer
12 views

Why do actions with class and public method don't fire __construct()

I'm trying to understand how WordPress works with actions, classes, and methods. If there is a class "TestClass" and it has a public method 'method1' The method can be hooked to any action ...
0
votes
0answers
16 views

Change or rewrite add to cart button functionality "

After clicking add to cart button by a user than i want to show checkout page in a popup instead of redirecting to cart, checkout pages. My purpose is to show checkout page in a popup after clicking ...
0
votes
0answers
12 views

Order category in shop page

i have this function to order for category the shop page in woocomerce function so_27975262_product_query( $q ){ //$q->set( 'category__in', array(96,105,97) ); if( !is_product_category() ) { ...
0
votes
1answer
34 views

do_action won't work in ajax callback

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('...
1
vote
0answers
18 views

How to remove action with slashes and arrows?

I have two actions like BSF_AIOSRS_Pro_Markup–>disable_astra_theme_schema and 'Yoast\WP\SEO\Integrations\Front_End\Redirects–>archive_redirect' on 'wp'. But I can't remove these both as usually ...
1
vote
0answers
47 views

Can the wordpress color palettes by changed through Javascript?

I'm building a setup for a client that allows them to use a number of colour swatches throughout their gutenberg blocks in a post. They define the colour swatches in the document inspector panel (post-...
0
votes
1answer
23 views

How to Override Page Template if URL matches query?

I have 4 Page Templates that my theme uses for all the pages - Default Template, Template One, Template Two and Template Three. When the relevant Page Template is selected, it loads an Advanced Custom ...
0
votes
1answer
15 views

Where do I hook to have the server do something in PHP on block attribute change?

I'm creating a new block plugin, and I'd like the server to do some stuff when certain attributes change. I'm thinking I'm looking for something like function my_attribute_changed ( $block_ID, $...
0
votes
0answers
28 views

Remove action using variable function from WP Residence Plugin

The WPresidence theme has an action in its WPresidence-core that generates a dropdown filter on the estate_property post type admin table page the I've not been able to remove. The function goes as ...
0
votes
0answers
14 views

I want to change the post status when the user click on preview

I want to change the status of the post from "draft" to "publish" when the user clicks on the preview button, then make a URL call and change the status of the post back to "...
0
votes
0answers
17 views

the wp_post_update isn't working all the time

When the user clicks on the preview I want to change the status of the post to "published" if not published and then reset my cache in my landing. Then after that, I want to revert the post ...
0
votes
0answers
23 views

WordPress Admin CPT custom action to add_action securley

I write this PHP code in my functions.php but I was wondering if this the correct way to do it (best way and security) Is this securely? What about the use of wp_nonce_url in the link? (is $_GET ...
0
votes
1answer
24 views

The function called on the wp head hook becomes null

Sample code: function test_loaded() { require_once 'file.php'; $ins = Sample_Class::instance(); require_once 'file2.php'; } add_action('plugins_loaded', 'test_loaded'); in file.php class ...
0
votes
0answers
30 views

Save_post - Warning: Cannot modify header information

I'm trying to populate an ACF field on save (updating or creating the post) while running a geolocate function using mapbox. I'm getting a cannot modify header information error when hitting the ...
0
votes
0answers
17 views

i create functions.php in plugin files but add_action ('wp_head', 'function_name') don't work

ı use add_action hook in my plugin but not working hook add_action('wp_head', 'cerezcss'); function cerezcss(){ ?> <!--cerezcssbaslangic--> <link rel="...
2
votes
1answer
32 views

Run add_action hook if condition

Is it possible to run add_action under a certain condition? For example, let's say I wanted to echo "Hello" in the header on the front page and then use the same function, but echo "...
0
votes
0answers
23 views

What hook to use for modifying the markup of blocks?

Wordpress had this Block "Gutenberg" Editor since version 5.0. Are there existing actions or filters you can use to modify the rendered HTML markup right from the server-side? If so, what ...
0
votes
0answers
13 views

Changing form action based on selected value

I am making a form using elementor pro. Is it possible to take an action following an user's choice? p.e. Question "Which Item do you prefer?" radiobutton1 - first item radiobutton2 - second ...
0
votes
1answer
30 views

WordPress How do I pass a variable from one add_action to another?

I'm trying to add a custom field on the checkout form if a certain product category is in the basket and then on submission, check that field has been completed and add the result to the order details....
0
votes
1answer
27 views

Sharing varible between two add_actions

I'd like to share a variable between two add_actions. Currently I'm trying to use a global. However it doesn't work. This simple example below illustrates the problem. In this example, ...
2
votes
1answer
44 views

How to prevent action in ajax request, when in admin side?

I have a plugin that hides certain posts in the frontend. For this to be consistent, I need posts to also be hidden in searches and AJAX searches (needs to work with any theme and search). To make ...
0
votes
0answers
8 views

Add_action increment value by 2 instead of 1

I am making a counter where I can count amount of posts ever posted on my blog and save the value in a option. I have created a function that gets executed every time I publish new post, but the issue ...
1
vote
0answers
9 views

How can I get my Script to work on the Login page?

I am trying to disable the right click feature, on the login page, using the following code: <?php function disable_right_click() { ?> <script> jQuery(document).ready(function(){ ...
0
votes
0answers
18 views

What is the earliest Hook a Script can use?

At present, I am disabling Right Click through the use of the following code: <?php // Disable Right Click function disable_right_click() { ?> <script> jQuery(document).ready(function(){ ...
0
votes
1answer
102 views

How do I trigger WP CLI DB export using a PHP function?

I want to use WP-CLI to export a database - using wp db export - to create backups. I also need to use cron to control the backup schedule. WP-CLI is installed on my managed host, and I can use it via ...
0
votes
0answers
24 views

Send Mail when coupon code is applied and order is successful

i tried with code below to send mail when coupon code is applied, though my requirement says when the order is successful and coupon code is applied it should send mail. add_action( '...
0
votes
1answer
13 views

If has action not working as expected

I'm using ACF Blocks in a theme I'm building. Here's my block template file within /my-plugin/template-parts/blocks/page-intro/page-intro.php: <?php /** * Page Intro Block Template. * * @param ...
1
vote
0answers
19 views

How to redirect if a background request is still being executed

I am using the Woocommerce Waitlist plugin to allow users to subscribe to product waitlists. After subscribing to a waitlist I want to redirect the user to another page to complete a form. I am using ...
2
votes
0answers
166 views

Is there a Woocommerce hook that fires when applying a coupon but before checking if it's valid?

I want to add an item to the cart (that same item gets discounted with the coupon) upon using a coupon code (with a hook). E.g. when using the coupon code SAMPLECODE, a product is added to the cart ...

1
2 3 4 5
27