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
0answers
11 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
21 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
25 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
13 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
26 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
18 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
17 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
20 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
16 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
6 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
7 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
17 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
41 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
12 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
10 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
16 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 ...
0
votes
0answers
32 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 ...
2
votes
1answer
31 views

Intercept request to /wp-content/uploads/random.file

I want to intercept requests to public files in WordPress, more specifically all requests to any file located in /wp-content/uploads. Using request or even init filters didn't help, e.g. add_action('...
0
votes
0answers
12 views

Override template with child theme on specific conditions only

I have a template override of the woocommerce checkout page in my child theme. However, I only want to override on specific conditions. Is there an easy way to do that? Let's say I only want to ...
0
votes
2answers
26 views

Send email to user when I publish a new post

i want to send email only new post publish in wordpress admin when i pulish anything its sending mail to user how to restric this to only new post added to send mail to user function ...
0
votes
2answers
27 views

Removing parent theme action on pluggable function not working

I'm trying to remove a parent theme's add_action call to a pluggable function, but can't get it to work by calling remove_action() - I have to redeclare the function and just leave it empty. Is this ...
0
votes
0answers
15 views

How can I send information when a order is completed to my own POS?

I have a POS made in PHP using OOP. Also I have my e-commerce in WordPress. So I would like to send the data when a order is completed to my POS. I already looked up for add_action and the hook of ...
0
votes
0answers
13 views

It is possible to hook the “product query” on database?

I have an api that has all my products already configured, it is possible to make a GET request on my API instead of making a query on my WP database to get the product. I've tried to find a hook/...
1
vote
1answer
17 views

How to add 'total' value to custom column title on the posts list page

I have added custom column to all posts page by this code: // ADD NEW COLUMN function len_columns_head($defaults) { $defaults['post_len'] = 'Symbols'; return $defaults; } // SHOW POST LENGTH ...
0
votes
1answer
17 views

Better use two dedicated methods hooked with add_action() to different actions, or can it be twice the same method?

This is merely a question about what's better in terms on performance, and general (WordPress) PHP Development. I deregister and dequeue a fewe scripts (and styles) from a WordPress website, in a ...
0
votes
0answers
21 views

Modifying a WordPress Plugin

is it possible to modify plugin by removing action and then adding a new with new function? In plugin I have this: namespace OCDI; class ImportActions { public function register_hooks() { ...
-1
votes
1answer
23 views

What is the first action or filter executed by wordpress?

To mesure performance of a wordpress website i need what is the first filter or action executed by wordpress ? it seems that index.php is the input file of server, there is a way to add a global time ...
0
votes
0answers
12 views

Action not included in the cron task

For some reasons, my cron task is registered with the right hook but the action does not exist. I would like to use a class method. So I have some questions... Do I need to wrap add_action() inside a ...
0
votes
0answers
20 views

Remove action not working in child theme

I am trying to remove action but it is not working: How can I remove this add_action('wp_footer', array($this, 'enqueueScriptsAsync'), PHP_INT_MAX); specific action in child theme? class TidioLiveChat ...
0
votes
1answer
15 views

How can I prevent a function from loading in the admin screens?

When I add this code to my theme's functions.php file, it crashes my admin panel. How can I prevent it from loading in the admin screens? //add_action('init', 'hekim_sticky_header'); // I want load ...
0
votes
1answer
30 views

Hooking into the HTML header container

I'm trying to hook into the header.php of wordpress theme(s) more specifically, right before the closing header tag </header>. I'd like to do this in a programmatic way so when I switch themes I ...
0
votes
1answer
32 views

admin_notices action doesn't trigger within save_post action

After the save_post action runs, I'm attempting to also use the admin_notices action and it doesn't work. What am I doing wrong? If I move the admin_notices action into the constructor, it works fine ...
0
votes
0answers
18 views

Preventing administrator to redirect from wp-admin or allow only admin to access wp-admin area

I am restricting non-admin users to access wp-admin using the below code. Also, block wp-login.php as well. For that, I have set up a frontend login page. function block_backend_access() { // ...
1
vote
1answer
11 views

Trigger a custom function when option are saved in admin area

I am creating a Wordpress theme from scratch and I would like to save a file with the theme option anytime the theme options change. I was thinking about: do_action('admin_init', '...
0
votes
1answer
43 views

Action Scheduler not running

I am trying to learn how to use the action scheduler so I am hoping somehow can give me some good pointers. I've got this code: <?php add_action( 'init', array( $this, 'wootomation_schedule' ) ); ...
1
vote
2answers
34 views

Calling plugin function inside custom plugin for onclick event

I want testFunction() to call check() that i created in my plugin php when i click My Button. How do i make it work ? <?php function createButton() { echo '<button onclick="testFunction()"&...
0
votes
0answers
27 views

Discern a specific plugin's action hooks

I'm new to Wordpress plugin development (but not to coding) so please excuse the question. I am trying to develop a plugin to catch user registrations and populate other web application databases ...
0
votes
0answers
40 views

Remove parent theme's remove_menu_page action in child theme

My parent theme removes the Comments section of wp-admin in the parent theme: function remove_all(){ remove_menu_page('edit-comments.php'); } add_action('admin_menu', 'remove_all'); I want the ...
0
votes
1answer
25 views

post value to function with Ajax and jQuery

This is how you would create a custom smart tag in wp forms: function ea_custom_smart_tags( $content, $tag ) { if( 'my_smart_tag' == $tag ) { $value = 'Testing 1 2 3'; $content = ...
0
votes
0answers
6 views

admin_notices hook is not working when the request method is POST

Trying to write a plugin and I have suddenly came to this problem and not sure what wrong I am doing. I know there must be something wrong but I cannot figure it out.. admin_notices work as usual, but ...
0
votes
1answer
57 views

Inject HTML meta tag inside wordpress <head> tag using add_shortcode

I am trying to add some meta-tag when shortcode [refresh url='http://stackoverflow.com'] tag is used. I have done below code, but it is not working, I want to inject HTML code between "<head>" ...
1
vote
1answer
48 views

Adding custom fields to bbpress reply form

Referring to post "adding-custom-fields-bbpress-topic-form" with link https://wp-dreams.com/articles/2013/06/adding-custom-fields-bbpress-topic-form/, I want to add custom fields to bbpress reply form ...
0
votes
0answers
39 views

remove_action not working for a function

I want to remove specific function from wp_footer action. This is what I added in functions.php of my child theme. remove_action( 'wp_footer', [ 'Fusion_JSON_LD', 'print_json' ], 999 ); In this line ...
0
votes
0answers
11 views

How to submit multiple nonces at once?

I have a form that incorporates three different forms from a plugin. Usually, each form would have it's own submit + nonce (which already exist and work), but I need to have just a single submit ...
0
votes
0answers
10 views

Woocommerce - change the order of DOM elements in single product page

Here's an example for a product in my website: https://lutra.co.il/product/%d7%92%d7%a0%d7%a8%d7%98%d7%95%d7%a8-5500w/ I'd like to have 'similar products' (מוצרים קשורים) shown before 'reviews' (...
0
votes
1answer
29 views

Is_Page doesnt detect my page

I want to call Servicedeneme.php which is in main folder of theme, in mysite.com/faq/ It's title is FAQ so I write code for two form which are faq and FAQ.However, it doesnt work. I write below code ...
0
votes
0answers
18 views

How do you insert code into the sidebar?

I would like to add code to the top of the sidebar. When I do: add_action('get_sidebar', 'function') It adds above the sidebar DIV. I would like to insert inside the DIV. If I do: add_action('...
0
votes
1answer
19 views

How Do I Unhook This Parent Theme Function?

In a parent theme I have a function like this, that removes hyperlinks from comments: function preprocess_comment_remove_url( $commentdata ) { //some code... return $commentdata; } ...
0
votes
1answer
35 views

save_post_{$post->post_type} action firing on second save

I have custom metabox checkbox on CPT in my plugin. I want to fire an action and save new option when I save this post. But no matter how many times I tried it's saving option value only on second ...

1
2 3 4 5
27