Questions tagged [hooks]

Method by which plugins and themes extend core WordPress functionality.

Filter by
Sorted by
Tagged with
0
votes
0answers
10 views

Trying to add an action to a custom post type

I have a custom post-type that I need to add a two state style button (Complete or Completed) The custom post type is a video so I want the client to be able to complete a workout. I am not super ...
0
votes
0answers
19 views

How to detect first pageload on successful login?

I want to print some JS on my site on the first page load after login - e.g. alert( 'You just logged in!' ); but there doesn't seem to be anything on the page (WooCommerce's /my-account, in this ...
2
votes
0answers
27 views

@wordpress/hooks use to add actions/filters within multiple plugin

I am trying to use @wordpress/hooks package in one of my react based plugin. I have added some hooks(filters/actions) and I need to hook into these from different plugin. I am able to add filter for ...
0
votes
0answers
16 views

Why isn't update_post_meta saving?

I am trying to concatenate 2 custom meta fields into one, and saving it to a new custom meta field. The data of those fields is created using a frontend submit plugin that uses the default WordPress ...
-1
votes
0answers
7 views

Is it possible to make every avatar shown on the page link to the wordpress profile?

we use wordpress + buddypress and would like to make the avatars of our blog-comments link to the buddypress-profile. Maybe there is a hook or something which makes that every avatar has this link? ...
1
vote
1answer
25 views

How to subscribe free subscription on user registration in woocommerce subscription plugin?

I am using Woocommerce Subscription plugin. I have two types of Subscription plans right now. Premium Subscription Free Subscription When any user registers on my site, I want every user to show ...
0
votes
0answers
10 views

Plugin to associate function to hook [closed]

I am looking for a plugin that allows creating functions in php and associate these functions to different hooks (e.g. wp_head). I need this so to be able to insert PHP without having to go backend
0
votes
0answers
10 views

Woocommerce: How to exclude some products with specific tag ID from Woocommerce REST API

I'm Working on a mobile app using the WooCommerce API and I need to exclude some products with a specific tag id from the /products endpoint. There no options on the docs on how to do this! just ...
-1
votes
0answers
13 views

Using a custom REST API in WooCommerce, the data from do_actions in content-product.php do not generate any output. Why?

I have WooCommerce v3.5.6 installed, and the code works as expected. But, if updated to any subsequent versions, all these do_action statements have no output over the REST API. do_action( '...
0
votes
0answers
13 views

woocommerce_add_to_cart custom function called several times

I´m trying to do specific action when the user add to cart for a WooCommerce Variation product. This is my code inside a Class : My Class { ... public function init(){ add_action('...
0
votes
2answers
33 views

Is my code correct to enqueue CSS on a specific page?

I am trying to load a CSS Stylesheet to ONLY the "about" page. I think I am 99% correct but what is wrong is the plugins_url - to link to the theme folder where I keep my CSS can I just use simply: ...
0
votes
1answer
37 views

WooCommerce: How to display item meta data in email confirmation using woocommerce_order_item_meta_end

Our store sells software and we're adding a software voucher code to each purchased. Once the purchase is completed (via the woocommerce_payment_complete hook) we generate the voucher code and add it ...
0
votes
0answers
21 views

Is it possible to have 2 Args with pre_get_posts?

Is it possible to use the pre_get_posts hook using two sets of args? For example, if I want to modify my main loop to first display all products that have a tag sponsored and then display all the ...
0
votes
0answers
16 views

Google Gtag or DataLayer Push not working within action hook

I used to use a function just fine but recently, perhaps because I corrected my implementation of Google Tag Manger and perhaps for other reason, I can't seem to use this code which is hooked to a ...
0
votes
0answers
23 views

Plugin function in child theme

I need to customize a message returned from a plugin function using my child theme. In the plugin: if ( ! class_exists( 'my_class' ) ) { class my_class { if ( ! is_admin() || ( defined( '...
0
votes
1answer
15 views

What hook should I use to add post meta data with on update?

I'm looking to use the bitly api to generate a shortened url for all posts and pages. My plan is to generate this when the post is saved, then save the shortened to the post when the API call is ...
0
votes
0answers
15 views

Copy a file after Wordpress update

I'd like to automatically copy a file after a Wordpress update. I tried with the upgrader_post_install hook, but it does not seem to work. Here is what I have inside the functions.php of my theme ...
1
vote
2answers
27 views

How to hide category name

I have a category about the catalog, news1 Which I use to get a post on the main page. The problem is that I don't want the news1 category name to appear in these posts, but I want other categories to ...
1
vote
1answer
21 views

Post Meta Emtpy on Publish Using Transition

I'm trying to use get_post_meta with the following hook, but it's always empty. I adjusted the priority to see if that would help, but no luck. Any ideas? The post meta is definitely in the db after ...
1
vote
1answer
31 views

Using a filter with multiple parameters and $this

I have seen various questions about this but I am unsure how to apply those methods in this particular case. I am trying to add a filter to a plugin which returns output with the apply_filters hook: ...
0
votes
0answers
7 views

How to Schedule (run) another Cron Schedule inside of a Cron Action

i am using this code to run a daily normal checkup cron... but i have another cron which will happen every ten minutes and update each user record according to my condition... but how do i run a new ...
1
vote
1answer
14 views

Add nofollow to custom widget posts

I would like to add the nofollow to my blog links in the custom posts widget. I think it could be done by filtering widget_posts_args but I am a bit lost on how to tweak that function. Any suggestions?...
0
votes
0answers
19 views

How can I change WPML settings programmatically?

I'm trying to change WPML settings programmatically, as suggested in these posts: Disable auto sign-in programmatically Overriding the WPML settings My goal is to disable a WPML's feature that ...
0
votes
0answers
16 views

Changing the “Post Published. View Post” admin notice message after running `wp_insert_post_data` filter

I am running a validation logic for when a user is attempting to publish a post, the validation is made possible using wp_insert_post_data filter. If a user wish to publish a post, the filter will ...
0
votes
0answers
13 views

How to pass custom_field value back to admin editor after field updated by a hook? AJAX? Other way?

I have a custom post type that has custom fields as meta data. The post is a lesson. As part of a lesson I have a webinar_id field. I typically don't edit that field directly, though I could if ...
0
votes
1answer
13 views

SEARCH QUERY PLEASE HELP | call_user_func_array() expects parameter 1 to be a valid callback php

Major issue with my search queries being outputted incorrectly on the blog page with respect to query's. In wordpress admin most relevant listed first but outputted DESC on page. I have this code in ...
0
votes
1answer
25 views

How to add custom checkout field in user details mail template

I need to add custom field from my checkout page to email templates. I already added custom input at checkout page and it shows up in mails but it shows up after products table and I would like it to ...
0
votes
1answer
28 views

ACF for custom post type archive pages: which hook to use?

I'm trying to register ACF options pages for each custom post type defined in the theme: $post_types = get_post_types( array( 'public' => true, '_builtin' => false ), ...
1
vote
2answers
29 views

Hook to change Logout url

I used this hook to replace the exit address . Now, unfortunately, this hook does not work and I can not understand why add_filter('logout_url', 'my_custom_logout_url'); function ...
1
vote
1answer
20 views

Disable block from editor based on post type

I've made a Gutenberg block which is only appropriate to show on hierarchical post types, so I want to disable it from the block inserter for non-hierarchical post types. I thought about how to ...
0
votes
0answers
26 views

Register/enqueue scripts only on certain admin pages

I found this question here but I'm a bit confused on how to proceed. I need to register or enqueue the bootstrap css for my plugin admin menu page. I've understand that when an admin menu page is ...
0
votes
0answers
17 views

Client side pre-save Javascript hook on all admin pages

I'm planning a Wordpress plug-in and new to the process. I have read about admin filters and actions which get executed server side. Is there any way of intercepting admin page submits globally on the ...
0
votes
0answers
10 views

Make category required

I want to prevent a post from submitting if no category is chosen. I don't want them to be automatically in the default category but really force the user to choose a category. I found this question ...
0
votes
0answers
14 views

Right filter for rewriting page statuscode

I am new to developing wordpress plugins. But I am looking to write a fairly simple plugin. I want to write a plugin that rewrites the returned status code based on some logic that consults a ...
0
votes
0answers
31 views

Woocommerce change the shipping method on the checkout page?

On my checkout page, I'm using Loqate to lookup an address and here in the UK I am able to retrieve whether this is residential or business. My intention is to change the shipping rate based on this. ...
-1
votes
1answer
25 views

Woocommerce: block user removing cart item

I've been tasked with creating the most awkward buying process my client could possibly come up with. When buying a product, the customer proceeds to a multi-step process where they build up a ...
0
votes
0answers
19 views

WordPress or WooCommerce hook when order is made, using Bank Transfer as payment

I was wondering if there is a hook I could use to trigger one function in the moment an order is placed, but only if the order is made with payment by Bank Transfer. For the online PayPal payments I ...
-1
votes
1answer
25 views

What is the difference between add_action and add_filter [duplicate]

I just want to know what is the difference between the add_action and add_filter. I just could not get it enough in the documentation of wordpress. Can anyone explain it more broader and simpler. ...
1
vote
2answers
31 views

admin_notices not working in post editor

I'm trying to fire an admin notice from within a pre_insert_term filter (have also tried it as an action). Example: add_filter( 'pre_insert_term', 'pre_insert_term_action', 10, 2 ); function ...
0
votes
1answer
27 views

How to use embed_content hook?

From the document of embed_content: Prints additional content after the embed excerpt. But I don't know which content it will print. Does it take any arguments?
0
votes
0answers
18 views

alter the main query on 404 error page to display content from another page

I have a normal page with content that can be maintained by editors via the backend. Now I want to display this content on the 404 page. So i tried to use the pre_get_posts hook to alter the main ...
0
votes
0answers
19 views

How to track product price changes?

I am writing an API plugin. Every time a product or quantity changes in woocommerce, I need to export a new price to the server. Also in the IPA there is import, which I will conduct through cron. ...
1
vote
1answer
37 views

What are the differences between comment_form_logged_in_after and comment_form_after_fields?

This is a follow-up question to this one. When hooking into the add comment form there are two hooks to use: comment_form_logged_in_after comment_form_after_fields Am I right in assuming that the ...
0
votes
0answers
12 views

Delete certain attachment fields only

I am using formidable and below is my hook code. The code deletes all attachments but i would like to delete only certain upload files . Is there a code that I can modify and add field number to be ...
0
votes
0answers
10 views

Post title only for front/blog page, category, archive, search etc

On any standard blog page dedicated to listing posts (i.e front, blog, category, archive, search etc.), I want to show just the post title rather than the post content. Example of desired output: &...
1
vote
1answer
21 views

Change Password Confirmed Email Text

I've been struggling to find a hook I can use to edit the text in the password confirmed email that gets sent out when you've changed your password in WordPress. Is there anyway to do this with a ...
1
vote
1answer
23 views

How to change image atributes right before an image to be saved?

I have an installed plugin to import XML content, but it can't change some meta-data of the new image that will be saved. For example, I'd like to intercept the action of saving an image BEFORE its ...
2
votes
1answer
23 views

merging an array to an existing array using add_filter

I'm working on a plugin and i want to be able to extend some of the functionality using apply_filters(). I have a setup like this which is the default values; print_r( apply_filters( '...
0
votes
2answers
40 views

Add filter return false not working

simple issue but i need some help because i dont why i m wrong on this... The apply filter (Important, this is in construct Class): if ( apply_filters( '...
0
votes
0answers
24 views

Edit plugin's HTML output with Hooks

I'm trying to edit the HTML output of a plugin, but I'm not sure how to do it properly. This is the code // display the heading $content .= '<h' . $heading_level . ' class="mbm-book-grid-heading' ...