Questions tagged [actions]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
156 views

Redirect users on specific post category or category page

im trying to redirect users on specific categry with this hook: // Show app-data posts only to app users function user_redirect() { if ( is_category( 'app-data' ) ) { $url = site_url(); ...
2
votes
1answer
272 views

Action 'save_post' not working for quick edit

I have read other answers to similar questions but none of them solved my problem. This code works great in Editor but on Quick Edit or Bulk Edit it does not appear to fire at all. What am I doing ...
0
votes
1answer
838 views

Filter WooCommerce archive pages by an additional category

I'm working on a WooCommerce bookstore site with a custom taxonomy.php template that generates different archive pages based on a category called "Highlights". So, for example, there is a "Best ...
0
votes
0answers
16 views

How to store additional data that is related to core data

Long story short, I am going to be building a web application with WordPress as the framework. We have to use WordPress, I cannot suggest a different framework. The application will have users with ...
1
vote
2answers
52 views

Search function works improperly

So I am trying to edit my Search so it searches only for specific categories. I am adding this code to my functions.php file in child theme: function searchcategory($query) { if ($query->...
0
votes
1answer
188 views

Using add_filters() , apply_filter(), add_action() and do_action() in extending a plugin

Suppose i am developing a plugin that is related too booking.Next time i want to add an add-ons on that plugin for payment.Then i added another add-ons for paypal payment. Assume that below is the ...
2
votes
2answers
854 views

How to change the blog title with add_filter? details below

i want to add a prefix to all the blog title by modifying the all ready applied filter . when i searched i got this: apply_filters( 'single_post_title', string $post_title, object $post ) what ...
1
vote
1answer
190 views

WP_Query ignoring tax_query when is_singular

I’m trying to set up some post permissions using taxonomies and I'm applying my rules in a pre_get_posts action. It’s working fine when multiple posts are found, but in class-wp-query.php near line ...
0
votes
1answer
315 views

remove_action - pre_get_posts - does not restore original query

I have following functions ... function ajax_sortposts() { global $wp_query; $sorting_order = $_POST['sorting_order']; if ( $sorting_order == 'Latest' ) { remove_action( '...
0
votes
1answer
568 views

Why does my wp_safe_redirect output the ERR_TOO_MANY_REDIRECTS error?

I've built a demo page and now I'd like to redirect on it whenever an user logs in and hasn't set up his theme, my code being: function add_admin_page() { if ( empty( $_GET['page'] ) || $_GET['...
0
votes
0answers
273 views

Change hook to add_action in a plugin class

<?php namespace wp_gdpr_wc\controller; use wp_gdpr\lib\Gdpr_Container; use wp_gdpr_wc\lib\Gdpr_Wc_Translation; use wp_gdpr_wc\model\Wc_Model; class Controller_Wc { const REQUEST_TYPE = 3; ...
2
votes
2answers
2k views

Remove action from a plugin class

<?php namespace wp_gdpr_wc\controller; use wp_gdpr\lib\Gdpr_Container; use wp_gdpr_wc\lib\Gdpr_Wc_Translation; use wp_gdpr_wc\model\Wc_Model; class Controller_Wc { const REQUEST_TYPE = 3; ...
4
votes
1answer
215 views

Does WP fire delete_post when trashed posts are automatically deleted?

I have a custom db table that stores additional post data and I need to delete posts from my custom table when the original post is deleted. Will WP fire the delete_post action below and run ...
0
votes
1answer
701 views

add_action template_redirect not working for home page

I am using bimber theme on latest wordpress. I wanted to force all frontpage views behind a login and added the following code in bimber's functions.php function members_only() { // Check to see ...
0
votes
1answer
375 views

add_action init breaks site on PHP 7.1

If there's no child theme available, I use a custom plugin for some minor changes. The following code for hiding update notifications etc. has always worked perfectly. However, if I switch from PHP 7....
0
votes
1answer
152 views

Automatically set post_parent value

I'm trying to set my blog posts as children of an /articles/ page. The URL structure is correct, but the breadcrumbs are not. If I manually set the post_parent column in the database to the /articles/...
1
vote
0answers
26 views

Are functions in main plugin file called before function bound to register_activation_hook runs?

In my plugin, I am doing a minimum-supported PHP version compatibility check via a function bound to register_activation_hook and halting activation for those on PHP version less than the minimum ...
0
votes
1answer
254 views

taxonomy_edit_form_fields output after term fields

I'm using the following code to create a custom metabox on a custom taxonomy page. $term_filter_name_edit = $type . '_edit_form_fields'; add_action($term_filter_name_edit, 'box_term', 1000, 1 ); ...
0
votes
0answers
222 views

wp_ajax add_action fuction won't fire on custom jQuery action

In general, I try to apply a "load more post" functionality to a loop, but I am failing to fire a PHP function within a plugin. The PHP function is supposed to fire using a custom jQuery action with ...
1
vote
1answer
2k views

How to change currency programmatically on creating order action?

A Payment Gateway I am using expects only Croatian currency so I am trying to update cart total and its currency by using a filter on placing order if the currency is Euro. I have successfully change ...
3
votes
1answer
171 views

Using wp_insert_post and post_update_meta but need to fire save_post afterward

I am using a calendar plugin. I have been using form data to create a new custom post type of calendar plugin and then update post meta custom fields for that calendar plugin. This works. However ...
0
votes
1answer
82 views

dynamic add_action according to child pages (for homepage control)

I'm using the plugin homepage control in many projects and really like what it does. I can create custom sections for my static homepage and can sort them in the customizer. In my recent client ...
2
votes
1answer
143 views

How to check if an action is already fired?

How to check if an action is already fired in a function for example: function foo() { // checking if the action 'wp' is fired if( !action_fired('wp') ) { trigger_error('invalid call'); ...
1
vote
1answer
301 views

Modify query in pre_get_posts action is messing up my nav menu

I am modifying the query for custom archive pages. I am using the pre_get_posts action. I need to catch some GET variables to modify my query. It is working great on the archive page for one custom ...
2
votes
1answer
177 views

Usage of do_action and add_adction

I'm trying to use add_action to add HTML output to a plugin's front end area, Below is the snippet from plugin <ul class="dashboard-links"> <li><a href="<?php echo $...
3
votes
3answers
766 views

Passing arguments into 'init' function

I'm trying to pass an argument in to the 'init' hook (please see below for what I'm trying to do). //define post type name $pt_name = 'post'; //remove default wysiwyg editor add_action('init', ...
0
votes
1answer
335 views

Remove action in a parent theme from the child theme

My question is how do I remove the action hook in the parent from the child theme? Code from my parent theme: if ( ! function_exists( 'wm_menu_social' ) ) { function wm_menu_social() { ...
0
votes
2answers
2k views

I can't seem to install Font Awesome locally [closed]

I tried searching but I can't seem to find a similar question so I am hoping that as an amateur, I am just making a big simple mistake. What I want I want to install Font Awesome to my WordPress ...
0
votes
0answers
490 views

Remove menu item dashboard for a unique user

I want to disable access to some pages like "Themes" or "Plugins" for my client (just his ID) and try to do it in the functions.php with this script: EDIT : WORKING CODE : function hide_menu() { ...
1
vote
1answer
568 views

'wp_login' action hook not working with wp-login.php file

Wordpress 4.9.5 I am work on demo to check after login call some action or function, so that i prepare one plugin. Here is the code. <?php /* Plugin Name: Test Login Plugin URI: http://wordpress....
1
vote
2answers
433 views

How to make content editable from admin page?

I have a landing page that has to be somehow converted into wordpress theme. And what I want to do is to make an admin page with editable fields that will correspond to the content on the front end. ...
0
votes
1answer
112 views

Remove action within a class in a parent theme's includes folder from the child theme

There's a class in parent's theme includes folder which adds action i want to remove in the child theme functions.php or in the plugin class A { public function __construct() { ... ...
4
votes
3answers
4k views

Send data to 3rd party api with wp_remote_post on wp_login

Is it possible to use wp_remote_post to send http post requests to 3rd party api's? I wasn't able to successfully save the user object as a javascript variable, so I was hoping I could make an http ...
1
vote
1answer
152 views

Can't unregister parent theme's CPT from my child theme

Here's how I create my CPT in my parent theme's functions.php: function my_custom_post_job() { ... register_post_type('job', $args); } add_action('init', 'my_custom_post_job'); I'm trying to ...
0
votes
1answer
18 views

Action for opening attachment or manipulating all attachment links

I am relatively new to WP-development and have now spent a while reading the docs and playing around but am of the assumption that the way I am trying to solve this problem is much more complicated ...
0
votes
1answer
57 views

remove different admin menu for specific users

Initially I intended to fetch user ID so I could show/hide certain menu groups in my plugin based on user status (which I added as a meta). The problem is that I can't use wp_get_current_user and ...
0
votes
0answers
24 views

Check if front page within function passed to action

I'm trying the following... add_action( 'wp_ajax_my_function', 'my_function' ); function my_function() { if(is_front_page()) { // do something } } For some reason it cannot detect if it ...
3
votes
1answer
466 views

Can i check if user is doing any ajax request?

I make a custom user meta and its name is last_activity. I use this meta to get the date of user last activity and I updated the meta each time user open a page using WordPress wp_head action. My ...
0
votes
1answer
378 views

remove_action() not working in page template - Genesis

I've had a good look around but can't find anyone with the same specific problem. In functions.php I'm adding the following actions: add_action( 'genesis_entry_header', 'twl_content_wrap_start', 15 )...
0
votes
1answer
167 views

Problem with removing plugin action

in my functions.php I try to remove an action from a plugin class. See both codes below. the remove doesn't work, but when I comment out the add_action (line 39) in the plugin class, then it works. ...
1
vote
3answers
208 views

Mustn't do_action be accompanied with a function?

Lets say we have a do_action like this: do_action('some_action'); Doesn't this mean that there has to be a some_action() function somewhere in the wordpress like this for example: function ...
0
votes
3answers
880 views

remove action from woocommerce file

i a have a woocommerce file "checkout-form.php". I want remove the following actions via functions.php <?php do_action( 'woocommerce_checkout_after_order_review' ); ?> </form> <?php ...
0
votes
0answers
68 views

How can I insert custom html code inside a div dynamically?

I have a class that generates some html code for me, namely the output_tooltip method: class Tooltips_Handler { private $tooltip; public function __construct( Tooltip_Base $tooltip ) { ...
8
votes
1answer
4k views

Please explain how these hooks work

I have read about hooks and actions and I know that when we see do_action('some_hook') it means that somewhere add_action('some_hook', function() {...}); or function some_hook() exists in a theme's ...
0
votes
0answers
282 views

Frontend AJAX Request causes Error: 'Call to undefined function add_action'

I wrote a little plugin that is supposed to handle a form submission and send some mails. When the form is submitted the request fails. Im on a local MAMP Environment and my PHP error log shows me ...
0
votes
1answer
24 views

Most performant/functional way to add actions/filters?

This question may seem trivial however as I see all of those styles very often I wonder if there is a difference (e.g. in performance or functionality): Possibility 1: function myabc() { } ...
1
vote
0answers
25 views

Adding widgets to my plugin page instead of WordPress dashboard

So below is the action to add widget in the WordPress dashboard. How can i add widgets in my plugin's page? add_action('wp_dashboard_setup', 'csc412_dashboard_widgets'); function ...
1
vote
1answer
141 views

Adding Default Settings to Theme My Login plugin

I am trying to update a plugin called Theme My Login with default settings. The problem is that the updates are only applied to the database. When I log into WordPress I can't see the options updated. ...
0
votes
1answer
387 views

WordPress Reset password Strength set to medium

I have been looking for an answer for a few days digging through hooks and actions. I just cane seem to find a way to turn down the strength on the reset password page not sure if its through woo-...
0
votes
2answers
27 views

Alter existing page contents based on url

I have a created a stuff page in WP. When a user visits stuff/foo, I'm want to fetch some data from an API append it to the contents of the stuff page. So far I've tried: hooking into the_content ...