Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [hooks]

Method by which plugins and themes extend core WordPress functionality.

0
votes
0answers
7 views

user_profile_update_errors hook not executing

I'm trying to use the user_profile_update_errors hook, however it doesn't appear to be executing. I'm calling it like this: add_action('user_profile_update_errors', 'blm_register_result', 10, 3); ...
0
votes
0answers
11 views

Custom register page and retrieving WordPress registration errors

I'm doing a custom login and register page and the login portion has gone smoothly as I can redirect errors back to my custom page because of how wordpress handles this (such as appending the issue to ...
0
votes
1answer
10 views

How can I add text to a specific 'Edit Page'?

I have a specific Page, that I do not wish to be edited. As such, I would like to place a 'Do Not Edit This Page' message within a specific 'Edit Page' file as follows: Any ideas on how this can be ...
0
votes
2answers
28 views

Issues with if, else, and elseif statements

For my site, I need to have different header colors depending on the page it's on. Here's the code I have for my site that is working: <?php if ( is_single() && is_post_type('product') || ...
0
votes
1answer
22 views

Validate custom fields before save using WordPress Rest API

I want to add custom validation to post(custom post type) before it save into the WordPress. I am using the Rest API to insert the post to custom post type. What I need is the fields which I created ...
0
votes
0answers
13 views

Add extra products on add-to-cart action

I'm having some trouble adding extra products on add to cart button is executed. Basically, the user gets a few extra products in the product to choose from, My problem is that the user can still ...
0
votes
0answers
19 views

How to do action after successful post save/update

On the frontend, users can submit a post, and when they click a submit button, javascript uses AJAX to publish the post to the live site. However, to automatically moderate the posts, I want to run ...
1
vote
2answers
134 views

Proper way of using functions in action hook?

I am wondering if the below logic is correct and if certain circumstances should be present for it to work, since in some cases it does not seem to be working. The example below is quite simple. Let'...
0
votes
1answer
8 views

Filter default_content only for products

Is there any way to use default_content only for a certain post type, specifically product (WooCommerce)? My code: add_filter( 'default_content', 'set_default_content', 10, 2 ); function ...
-1
votes
1answer
24 views

How to filter part of a variable if it is no array?

I was wondering if it is possible to filter out a part of a variable, if it is no array. Or can I only replace the whole code, or add code to it? Let's say I have this code: $output = '<...
0
votes
0answers
12 views

Is it possible to change existing shortcode?

There's a theme using cornerstone visual composer and it's shortcode [recent_posts]. I want to change it's behoviour, because it sets featured image as background in the following way: <div style="...
1
vote
1answer
45 views

hook to get (and change) the search string before processing

I'm trying to intercept the search query before it's executed in Wordpress. I've tried a bunch of things but it's just not working. So, for example, a user enters the search term RED SHOES. I want ...
0
votes
0answers
19 views

Woocommerce checkout field autocomplete and delivery by city

I am trying to implement a customized delivery option given by the city the user has chosen. In order to do so, I started with adding a basic js autocomplete on a closed list of cities, The problem ...
-1
votes
1answer
30 views

Cannot modify header information - headers already sent

So I have a form on one page, which is submitting to admin-post.php, then there is a function in functions.php which is processing the form. It stores the input field data to database and then after ...
0
votes
2answers
18 views

Remove an action by extending class and replacing it

I'm trying to override a method (my_packages) from the WP Job Manager Paid Listings plugin by extending it's class from within a custom plugin Here is how the source code (none-related code removed) ...
0
votes
1answer
12 views

Why is pre_get_posts hook invoked multiple times?

I am using pre_get_posts hook, however as it is not working as expected, I have discovered that the function is being invoked 4 times, and while the first call is running as expected, subsequent calls ...
0
votes
0answers
20 views

Having trouble using wp_update_post

I am trying to create an action that will place the contents of a meta tag into the excerpt field, but I can't seem to get it right. The action is the publish event of a frontend submit plugin. When ...
0
votes
0answers
15 views

WooCommerce Custom Pagination Layout

as currently my site product pagination is display as PREVPAGE 1 2 3 .. 15 NEXTPAGE May I know how I can make it as FIRSTPAGE PREVPAGE 12345 NEXTPAGE LASTPAGE ? I'm trying to achieve it same as https:...
3
votes
1answer
27 views

Restrict access to admin but allow admin_post hook

I'm using this hook to allow only admin roles access dashboard add_action( 'admin_init', function() { if ( defined('DOING_AJAX') && DOING_AJAX ) { return; } if ( !...
0
votes
0answers
14 views

Woocommerce filter don't work

I noticed that some Woocommerce filter not called as needed. For example in cart view page must work filter 'woocommerce_get_item_data' but this filter not works, I wrote code in theme functions.php ...
0
votes
2answers
30 views

Custom action on login and “remember me”

I try to call a function everytime a user login to website. I succeeded with the wp_login hook for user who fill the login form. However I can't find a hook for an user which has the "remember me" ...
2
votes
1answer
43 views

Best practice custom function, where to echo the variables?

I have a custom function to query some posts. I was wondering if it is okay to echo variables within the loop of the function, since normally I would echo a variable at the end of the function. If so, ...
0
votes
0answers
20 views

Country specific pages in a site

I’m working on an multi-national site for which the sponsors want pages supported so that each page: Can be served from a single default page regardless of the country (80% of pages), and Default ...
0
votes
0answers
25 views

Need help registering a new template location into an existing Elementor action

I'm trying to find a way to register some new "template locations" within the Elementor page builder system. They have two page templates that come with the plugin, "Elementor Canvas" and "Elementor ...
0
votes
1answer
29 views

Don't prepend WordPress base url to image paths

I'm programmatically adding image attachments to posts, however I'm not uploading the image, just storing the full url which is hosted on a CDN e.g. https://i.atcdn.co.uk/imgser-uk/imgser-uk/servlet/...
0
votes
2answers
22 views

Transform .wp-video to the native video player of the browser

Is there a way to display a video using only the default video player of the browser, without the mejs / wp-video interface? The additional markup gives me a lot of trouble. I just want to use the <...
0
votes
0answers
33 views

Remove woocommerce actions for frontpage

basically i want to remove the default single product actions that woocommerce uses but only on the front page. To attempt this I first just removed the actions like so: // woocommerce hooks for ...
0
votes
0answers
13 views

How to change layout regarding of post_type?

I have a custom post type and those posts gets displayed on a layout. Normally I could just set the layout on editing, but I want to automatisate that. Simply put, how to set a layout/page_id when the ...
0
votes
0answers
20 views

replace a string inside a php file through functions.php

Just a noob question maybe ridiculous but I wanna give a try. Let's say I have a child theme and I have installed a plugin that I really like but in this plugin I want to change a string in this way ...
0
votes
0answers
14 views

User role hook on every change

I am actually developing a plugin to sync user roles to another database. I am using the set_user_role hook and it works in most cases. My problem now is that another plugin changes user roles ...
0
votes
3answers
31 views

Get user custom field value on function.php

I created a function in function.php which send an email with user information at registration. I succeed to get the ID but I can't get custom fields... I only can get these ones : - ID - ...
0
votes
0answers
21 views

Removing action added from within a class

One of the plugins we use have this code: class MailChimp_WooCommerce { private function activateMailChimpNewsletter() { $service = new MailChimp_Newsletter(); if ($this->...
1
vote
1answer
35 views

How to display post content instead of excerpt

I am using a plugin, and to get around something I need to add some text to the excerpt field on my posts, but I don't want to display the excerpt field data on the front end, but rather the post ...
0
votes
1answer
16 views

Using delete_attachment to prevent an attachment not working

I'm having an issue where the attachment is being deleted despite me returning false function action_maybe_delete( $id ) { echo "Let's not delete Attachment id: " . $id ; // prevent the ...
0
votes
2answers
19 views

Insert HTML in post, below nav bar but above content?

I'm trying to insert a dropdown (via HTML string) in to every post I have. I'd like to add it before the post information, but below the website nav. bar and header. In the screenshot, you'll notice ...
0
votes
0answers
15 views

Intercept password prior to wp_update_user committing and hashing?

I'm using a plugin that uses wp_update_user instead of password_reset and I need to use the password prior to hashing to sync the change to a secondary authentication system. Is there any way to do ...
1
vote
1answer
28 views

Add function to every post?

I have some code that generates a dropdown list of all my post files. I would like to add this dropdown to the top of every post page, right before the post content. What's the correct hook/action ...
0
votes
1answer
22 views

Hook into all password resets in Wordpress and get password before hashing?

I'm syncing my Wordpress authentication system with an secondary/external authentication system and my site has at least two ways of resetting the password, including: Password reset email User ...
0
votes
2answers
17 views

Control the srcset much more (not all sizes in it each time)

I'd like to be have more control on the srcset on certain important images of my website if not all. By default the srcset includes all the sizes created by wordpress for all the images. I'd like to ...
0
votes
0answers
15 views

How to add google tagmanager to default registration page?

How I add google tag manager to default registration page? So Ill can track the registration flow? Ill need to add a google the tagmanager script to the head and a tagmanager noscript to the body of ...
0
votes
1answer
82 views

WooCommerce Hook: Content get's displayed twice and not AFTER the order total

I've overwritten WooCommerce's review-order.php to change the checkout a little bit. Now everytime I add something to the hook woocommerce_review_order_after_order_total the contents get displayed ...
0
votes
1answer
90 views

OOP development and hooks

I'm currently working on writing my first OOP Plugin for Wordpress. To help out a little bit with structure I looked for, and found, a boiler plate that sets up the basics for me. In Main.php there'...
1
vote
2answers
50 views

Set meta field to publish date + 2 weeks

I have a meta field called postexpiry, and I want to set the value to the publish date, + 2 weeks. So if today were October 3rd, I want the field to be set to October 17th. I was thinking about ...
0
votes
0answers
24 views

Why always one post missing in wp query loop

I know this is duplicate of Why always one post missing but the solution suggested to use Hikari Hooks Troubleshooter plugin which was last updated 8 years ago and I was not able to comment on the ...
0
votes
2answers
89 views

Woocommerce - Adding row to cart table

I would like to add an extra row to the Cart Table in Woommerce, but I can't find the right action. From this file https://github.com/woocommerce/woocommerce/blob/master/templates/cart/cart.php, I ...
-1
votes
1answer
23 views

Add PHP code to header section from plugin

How can i add any type of PHP code to header section through plugin programmatically ? I did use add_action('wp_head', 'your_function'); function your_function() { echo ...
1
vote
0answers
72 views

WooCommerce order complete email logic

Can someone helps me to understand the logic of WooCommerce for sending email on a completed order? If I'm not wrong, the mail is send when the order is marked complete, but I'm not able to find the ...
-2
votes
1answer
27 views

How to display <div> before H1 Title

I need display custom block before H1 Title in my posts. Please, tell me. Is there any function or hook to implement this? I cant edit file single.php, because I create different single templates ...
0
votes
1answer
29 views

Needing to add a conditional PHP statement for woocommerce webhooks

So in a nutshell I have a code that checks if an item is listed with a price or not on my website. If there is no price, or the price is 0 it currently shows "Call # to Order" My problem is I need ...
1
vote
0answers
31 views

How to add an arrow to menu items has submenus

I want to add arrow (or anything like ...) after every menu item that have children menus. I know that there is some JavaScript solutions. But for some reasons (stability and ...), I don't want to ...