The Stack Overflow podcast is back! Listen to an interview with our new CEO.

All Questions

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

Post is uncatagorized in publish_post action

I've added several bits of metadata to my post categories. When that post is published I want to copy some of those meta values into the custom fields of that post. add_action('publish_post','...
0
votes
0answers
33 views

Nested Actions and Filters

It is possible and a good practice to combine filters and actions, it is necessary to take into account the order in which they are executed, a graphic example https://images.app.goo.gl/...
1
vote
0answers
22 views

Unable to change footer using wp_footer action hook

I am learning Wordpress from a book and while learning about how to use action hooks the author gives the below code . I am assuming this would change the footer at the front end . <?php ...
0
votes
1answer
36 views

Use wc_enqueue_js only on specific pages - nested add_action

In my plugin, I'm trying to add inline script using wc_enqueue_js only on the cart page. The rest of the plugin is also executed only on the cart page. The code below works fine, but I don't like the ...
0
votes
0answers
23 views

How to find out the page name or slug inside a filter?

How do I find the page name or page slug inside a filter in a plugin? I am customizing a plug-in and I need to run some code based on which page is currently being displayed. The code is inside a ...
0
votes
1answer
37 views

When does save_post hook fire on post save/update

In my plugin I want to update sitemap every time page or post is created/modified. To achieve this I use save_post hook: add_action( 'save_post', 'update_sitemap', 10, 3); Upon creating/saving/...
0
votes
0answers
26 views

How do I remove an action hook inside a class that is called by another class?

Okay, so I am using the "FooEvents for WooCommerce" plugin for making WooCommerce products to events. And now I wanna replace their WooCommerce hook 'woocommerce_order_status_completed' with my own. ...
0
votes
1answer
36 views

Passing function into add_action always returns the first argument

I'm building a plugin that iterates across and parses the arguments of various WordPress hooks, and because of the flexibility needed I'm passing a function as the callable parameter in add_action: ...
1
vote
1answer
26 views

wp_set_object_terms not updating database without a die()

I have added custom taxonomy to media attachments. From the individual post page these are updating correctly, with some tweaks to get the column count updating correctly - and I can see these changes ...
3
votes
0answers
30 views

add_meta_boxes action with refresh on save

I've created a meta box using add_meta_boxes action and it works when I open any post to edit it. add_action('add_meta_boxes', function() { add_meta_box( ... ); }); When WP auto ...
0
votes
0answers
48 views

WordPress Plugin Boilerplate - add actions and/or filters based on user's role

I am developing a plugin using WordPress Plugin Boilerplate. Some of its functionality need to be available only when a shortcode gets resolved in a page and furthermore some of it only if a user is ...
0
votes
1answer
52 views

Get post content inside plugin class method

I'm writing a simple SEO class that will add the various metatag to the header of wordpress. I've two little problems with the wordpress api. The first is that I need to remove the last comma from ...
0
votes
0answers
36 views

do_action from within a class does not seem to work

I have a class within a plugin which is loaded via the below code: <?php add_action( 'plugins_loaded', array ( 'Company_Store_Locator', 'init' ) ); class Company_Store_Locator{ public ...
0
votes
0answers
31 views

Execute my Custom Plugin's function in WP Admin

So I am developing this wordpress plugin for WP Admin. I am able to call different views and function by using this URL structure. /wp-admin/admin.php?page=imported_isbns_list and it executes the ...
0
votes
0answers
21 views

Add_filter not return any output in custom plugin

I am using WordPress Boilerplate plugin structure to create a custom plugin.Add_action works but add_filter function not returning any output. Here is my code. includes/class-post-rating.php file ...
0
votes
1answer
49 views

add_action not calling back to function

I am working on a plugin, but add_action doesn't call the callback. The code is as follows: require plugin_dir_path( __FILE__ ) . 'includes/class-network.php'; $distro = new Classnetwork(); ...
0
votes
0answers
23 views

What is the recommended way to save errors / warnings / user messages from actions / filters for custom display in the frontend?

This is a very basic question and there are a lot of solutions to it - however what is the recommended (or at least a good) way? Problem statement: While processing a request to a WordPress project ...
0
votes
0answers
45 views

Remove action added in plugin class from theme

I am trying to remove action that is added via plugin in my theme. The below plugin class creates a portfolio page template but I don't want this page template in my theme. Is there any way to unhook ...
2
votes
1answer
50 views

Modifying values with add_action to be sent to db

I am struggling with this problem for hours now, what is going on is that somewhere before inserting the values into the db, this action is being called. do_action_ref_array('h5p_alter_user_result', ...
1
vote
0answers
31 views

Get Time Taken By Each Action Hook in Wordpress

I am developing a Plugin, and want to record Time taken by each Action Hook, I am able to get all the Hooks Triggered on a Page with the Action and Priority, but i am unable to get the Time taken by ...
0
votes
1answer
529 views

How to run an add_action hook for specific page

I have a function that loads a script for validation and i want to add it for only 'login' page. this the function: function include_regForm_validation() { wp_register_script( '...
1
vote
2answers
481 views

Why The Init Hook For Custom Post Types

I have a question about this documentation. Why would I register a Custom Post Type in the init function as the docs suggest? Is this only if I am not using a plugin? As I understand it, init runs ...
1
vote
2answers
139 views

wp_transition_post_status does not change the status of the post

For some reason, I have to unpublish certain posts every time wordpress loads. This is my code: function af_change_post_status() { $notpayed_posts = new WP_Query( array( 'meta_key' ...
4
votes
1answer
212 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 ...
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
0answers
158 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
491 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....
0
votes
1answer
51 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 ...
1
vote
0answers
24 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
139 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
342 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
1answer
49 views

echo plugin results on pages

I am trying to get a query to echo on the frontend of wordpress from a plugin but haven't had much success. Any and all help would be greatly appreciated. Below you will find the simple script I am ...
2
votes
1answer
755 views

Woocommerce - Hide a Column in Cart Table

I want to hide or remove a column from the cart of woocommerce, Im making a plugin for woocommerce so it wouldn't be good to modify directly cart.php or functions.php (which would be the solution) but ...
0
votes
2answers
2k views

Submit Form data to another page via Ajax (Wordpress Way)

I have the following form <form name="interest_calculator" id="interest_calculator"> <input type="hidden" name="action" value="calculate_investor_interest" /> ...
-1
votes
1answer
64 views

Insert plugin html content to a specific spot in the frontpage

I'm trying to insert plugin html content to a specific spot in the frontpage of a site. The site uses the Divi theme. I'm trying to avoid putting any code in the original Wordpress or Divi theme ...
0
votes
1answer
542 views

How to pass variables to a function argument using add_action [duplicate]

I have a test.php plugin file inside my plugin/ folder and I am trying to send an email from this plugin. I have a code that looks like this currently in my plugin. add_action('init', '...
1
vote
1answer
451 views

What's the difference between hooks, filters and actions? [duplicate]

It seems like the terms hooks, filters and actions are used interchangeably. What's the difference between them? What do they do? How do I use them?
0
votes
2answers
621 views

How dynamic action login_form_{action} is working

I found this action hook in wp-login.php file. It says it can be used to create custom actions to the wp-login. However, as I'm new to WP coding and PHP, I do not understand how {action} can work even ...
2
votes
1answer
549 views

Action on post publish

I want to do something when a post is published (doesn't matter if updated [draft -> publish] or just created) In my plugin I tried different actions to try this. I tried the following code to detect ...
4
votes
1answer
2k views

How do you use the plugin boilerplate loader class to hook actions and filters?

The Plugin_Name_Loader class of the WordPress Plugin Boilerplate is very useful if you must hook into a WordPress action or filter from your plugin. The original author, Tom McFarlin, says the ...
0
votes
1answer
38 views

How to find list of all functions bind to a particular hook from my plugin?

I want to remove all actions attached to admin_notice hook in my plugin at the time a user updates the plugin. Is there any way to find the list of functions attached to admin_notice hook by my plugin?...
1
vote
1answer
17 views

Tried in different ways but sidebar not working?

function Y_widget_register(){ register_sidebar(array( 'name'=>esc_html__( 'Sidebar', 'Y-07' ), 'id'=> 'y-sidebar', 'description'=>'Dynamic Right Sidebar', 'before_widget' =...
1
vote
1answer
293 views

Custom plugin init action causing general slowness

I'm developing a custom plugin which connects to salesforce and needs to check that the connection hasn't expired on each page refresh. If it does expire, it reconnects etc. So I am doing this on an ...
0
votes
1answer
547 views

Action Hook Inside Wordpress Plugin Shortcode

I'm developing a Wordpress plugin and I'm having trouble getting $_POST data using an action inside my shortcode. The form I'm parsing is on a page that I've added my shortcode to. Here's what I've ...
0
votes
0answers
352 views

add_option_{$option} action hook not being called

I'm trying to write some files to the server when the settings for my plugin are saved. I'm using the Settings API and a class that looks like - class AAPF_Admin { public function __construct() { ...
3
votes
1answer
56 views

Actions or filters fired when data is saved in a custom table

I'm using a plugin, and I'm trying to auto-populate a custom field (dropdown) for the subscriber form, because it should list some dynamic data (related to the websites content). The plugin has, as ...
3
votes
4answers
246 views

Enqueue style inside shortcode but its loaded at the bottom of page (before footer scripts)

I added/enqueue a style inside shortcode, it works fine but loaded in footer (before starting the .js files) rather than header. I did the same way like this solution: Enqueue Scripts / Styles when ...
0
votes
1answer
24 views

Submit to itself don't work

Currently I am creating site wordpress.lockout.lt. One functionality is developed by me; it works fine with the default theme. Currently I am using a different one. And as well this theme requires lot ...
0
votes
2answers
185 views

Does using `add_action( 'init'…` cause performance issues?

Am I using add_action('init' correctly? I want to display some data if a user visits example.com/?my_plugin At the moment I'm using... <?php add_action( 'init', 'my_plugin' ); function my_plugin(...
2
votes
2answers
3k views

How to register custom post types in a plugin?

I'm using toscho's Plugin Class Demo code as a foundation for a plugin I'm developing. Amongst other things, my plugin registers a custom post type. public function plugin_setup() { $this->...