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

learn more… | top users | synonyms (2)

0
votes
1answer
22 views

Pass arguments to function class with do_action()

I'm trying to develop a "simple" script where i can create a filename with a timestamp of the last edit. For this I'm trying to code a class – but I'm having problems to pass an argument to ...
2
votes
1answer
682 views

WP Login forms action URLs displayed as pretty URLs in browser (ex with Restore Password)

I would like to use the WP native login/register/restore password/.. functionality, but display pretty URLs instead of wp-login.php I've been looking at the core code and noticed that most login ...
0
votes
1answer
40 views

Understanding and using did_action() in a conditional statement

I'm working with Genesis Framework in a custom theme, but this is not a question "genesis-specific". I need to populate the sidebar of my pages (not posts) conditionally. The condition is to check ...
1
vote
3answers
2k views

How do I hook a sidebar via add_action?

On one of my templates I have an action hook 'do_xyz' I want to attach a custom sidebar to the action hook do_xyz Here is what I am trying in my theme functions.php file, does not work: ...
1
vote
0answers
19 views

Wordpress form. Variables to display on other page? [closed]

I'm using Ninja Forms, and I'm working on a form where when the users presses "ok" then the page is supposed to go to another page which shows specific information and links for that user. Right now ...
2
votes
1answer
487 views

Restrict post edit/delete based on user ID and custom field

I've been able to prevent deletion and editing of posts based on user ID and page ID however, I need to restrict access to editing and deleting based on a custom field. Not sure how to go about doing ...
1
vote
1answer
586 views

wp_logout action not working

I'm trying to remove some cookies set to control persistent login when the user specifically wants to log out of a website. I thought it would be as simple as: function remove_user_cookie() { ...
1
vote
1answer
27 views

Insert term when page is published - avoid duplicates after edits

So i want to dynamically add terms to a custom taxonomy named after new pages when these are published. Problem I have is that when you edit the page titles, another term will be added to the ...
0
votes
2answers
464 views

stumped on add_action hook to delete_comment - any ideas?

I'm pretty new to plugins and trying to run a function when deleting a comment. This entails hooking into "delete_comment" if I'm not mistaken. ...
29
votes
3answers
12k views

remove_action or remove_filter with external classes?

In a situation where a plugin has encapsulated its methods within a class and then registered a filter or action against one of those methods, how do you remove the action or the filter if you no ...
1
vote
1answer
791 views

Using add_filter() in Widgets

Just have a query reference the add_filter() function. Can you use this function inside a WordPress widget class. Example I have a widget with dynamic created code that I want to pass to another ...
0
votes
1answer
14 views

save_post not triggered when a post is updated

I'm encountering something weird. I made a function on functions.php that I want to trigger when a post is saved or updated. function gh_set_inner_project_order($post_id){ $parent_id = ...
0
votes
1answer
18 views

Remove action added through function

A theme I'm using modified a woocommerce that I'd like undo in my child theme. It's been added as shown: function theme_setup(){ remove_action( 'woocommerce_before_main_content', ...
0
votes
2answers
52 views

How to get a single hook from wp_head()?

I am working on a custom post type and I don't want it to get all the clutter from wp_head(). However, I do want to show a specific hook, for example the YoastSEO meta tags. How do I call a specific ...
3
votes
3answers
3k views

Check if action hook exists before adding actions to it

I am trying to add a rel=next and rel=prev link tags to the head element of image.php template file. I have Wordpress SEO installed and I like to hook to this plugin wpseo_head action hook to achieve ...
-2
votes
0answers
11 views

Output Diffrent Tablerows after loading the same Wordpress Side with a Shortcode in the Content where the table will be shown

i know currently how i can add a shortcake for my Plugin that will output an table with 20 Rows of information and also a navigation bar for the previous 20 rows. But I still could not find out how to ...
0
votes
1answer
859 views

Add content after get_header

I'd like to add content directly after the div#main (end of header.php) and before /div#main (beginning of footer.php). I'm using an own child-template (of twentythirteen), that contains only ...
0
votes
0answers
52 views

Filters, priority when run after plugins_loaded

In my main plugin I filter the_content to add rich snippets. Something like this: add_filter('the_content', 'add_schema'); function add_schema( $content ) { $schema = NULL; //To avoid undefined ...
0
votes
1answer
2k views

Action hook “wp_insert_post” works but not for last imported post

I want to run a custom function whenever posts are imported to my custom post type. I am currently running this code - function on_post_import($post){ global $wpdb; $results = ...
1
vote
1answer
36 views

Wait a result before enqueue

Supposing we have : class AwesomeClass{ private storedResult; private __construct(){ add_action( 'set_logged_in_cookie', array($this, 'a'),10,1); ...
0
votes
1answer
23 views

previous_post_link inside of a function?

I'm missing something on how to call previous_post_link() inside of a function. I also tried assigning the output to a string variable and using that. function prevnext( $content ) { $content .= ...
0
votes
1answer
966 views

get_term and get_term_by return null or false, even though term exists

I am trying to use the action hooks delete_term and delete_$taxonomy, among other hooks that delete a term, but they are presenting the same issue. For example, 1234 is an existing term in the ...
3
votes
1answer
648 views

Deactivate plugin for a specific user group

I would like to deactivate a plugin for a specific user. I'm using the following code inside a the wp-content/plugin-mu plugin file: add_filter( 'option_active_plugins', 'bo_disable_apm_plugin' ); ...
0
votes
2answers
2k views

How to append new form elements in “Add New” form of Users in Wordpress admin panel?

I'm developing a WordPress plugin and I want to append some extra form fields in add new form of Users section inside admin panel without editing core files. Can somebody help me in achieving this.
0
votes
1answer
518 views

Create action running on trashed_post hook to modify post_meta value

I have a custom post type that always do math operation to its post_meta and other custom post type post_meta. For example: post-type 1 = cpt_product_order post-type 1 post_meta = ...
3
votes
2answers
428 views

How to modify wp_ajax function?

I want to modify wp_ajax_find_posts function. It receives search string from find-posts form and delivers search results by ajax. Part of the function looks like this: function wp_ajax_find_posts() { ...
0
votes
2answers
38 views

How to pass parameters to admin_notices?

So there is the following case. I need to display a name inside of admin_notices. class MyPlugin_Admin { public static function render_admin_notice() { echo $name . ' has been ...
4
votes
1answer
117 views

How to do_action and get a return value?

So there is the following scenario. I add an action to clean logs from the database: add_action( 'myplugin_clean_logs', array( 'MyPlugin_Logs', 'clean_logs' ) ); Now I want to run this action ...
0
votes
0answers
17 views

Run javascript code after “woocommerce_payment_complete” action hook

I am trying to fire custom javascript code after successful payment in woocommerce. Code that I use so far: add_action( 'woocommerce_payment_complete','mysite_woocommerce_payment_complete' ); ...
1
vote
2answers
3k views

When is admin_init Action ran?

I have this function below that is called with the admin_init Action function my_flush_rewrites() { global $wp_rewrite; $wp_rewrite->flush_rules(); } Like this ...
0
votes
1answer
44 views

Why doesn't a form need an 'action' with a plugin that uses the post data?

So I'm still rather new to WordPress plugins. And there's one thing that I'm not sure of. I'm building a front-end form that allows users to post posts. In this guide down below there's a plugin made ...
0
votes
1answer
17 views

I can't enqueue Suggest.js in frontend - not added

my suggest.js is not being added in front-end. All scripts are correctly loaded but this one. I want to load it only on frontpage so: add_action('wp_enqueue_scripts', 'homescripts'); function ...
16
votes
4answers
11k views

How to know what functions are hooked to an action/filter?

Is there a way to know what functions are hooked to a particular hook? For example if I'd like to know what functions are hooked to the wp_head hook.
0
votes
0answers
24 views

register_nav_menu & add_action & in AJAX callback

Is it possible to call add_action or register_nav_menu in AJAX callback? I.e. add_action('wp_ajax_some_ajax_action','ajax_callback'); function ajax_callback(){ ...
0
votes
2answers
333 views

widgets_init actions not fired from functions.php's child theme

I need to add new sidebars for using them accordingly on different pages throughout my shop. I use Woocommerce and my own Storefront child theme. This is a snippet of what is in functions.php file ...
0
votes
0answers
33 views

remove_action not working with procedural function

I have a purchased theme that procedurally loads an action like this: function func() { echo "head content"; } add_action( 'wp_head', 'func', 5 ); Following the remove action codex I tried the ...
3
votes
1answer
18 views

When should I call add_settings_section and add_settings_field?

All of the examples I've seen for add_settings_section & add_settings_field have them being called on the admin_init action. This means that they're being called when loading every single admin ...
0
votes
1answer
19 views

'Conflict' with action deleted_post and is_admin()

I created a delete button on frontend for blog posts and custom type posts and I would redirect to a specific page after deleting them, I looked around on google and I found all solutions like this: ...
3
votes
1answer
451 views

Check php version before theme activation

I've got theme that requires php 5.3+ version. If older - fatal error occurs with it. So what I need to do when user try to activate this theme is to check php version before going into theme code ...
1
vote
1answer
1k views

Using several add_action with parameters inside a class

I'm creating a theme framework and using a class to initiate all basic function of the theme (adding theme support, menus, etc). I've got stuck when I tried to enqueue the scripts and styles though: ...
3
votes
2answers
80 views

WP Schedule Event - Every Day When First Visitor Comes

I have a daily wp schedule event. I know that it happens when a user visits the site and if a schedule time passes. If I started it on today 12 a.m. and if tomorrow first visitor comes tomorrow ...
3
votes
1answer
2k views

Add something to beginning of the content

I'm using add_action('the_content', 'myFunction', 10) to append data to the end of the content. How can I place content at the beginning of the content?
0
votes
1answer
17 views

Use has_filter on comment_post

I hook to comment form (on comment_form_logged_in_after if user is logged in and comment_form_before_fields if not) to add 2 fields (rating and title). These fields can be mandatory or comment will ...
0
votes
1answer
400 views

admin_notices on runtime in function

I have a function that is called at a post updated, inside of this function I am doing something and if this went wrong I want to display an admin_notices. Inside of my function I tried the ...
0
votes
2answers
25 views

Dequeue, Unregister, Remove Action - Not Working on Plugin

Several years ago, not really having a handle on the best practice for running a MultiSite network, I often network activated plugins. Later I realized this was a mistake because not all the sites ...
1
vote
2answers
50 views

Remove Action from Plugin within extended class and no assigned variable

I have tried so many solutions for this but I can't figure it out. Here is a simplified version of the plugin code: class YITH_Vendors_Frontend_Premium extends YITH_Vendors_Frontend { public ...
1
vote
2answers
5k views

add_action and wp_head not display content in head section

I have a big problem. In a Wordpress page I've a function that generate og meta tags. I want to "append" that generated meta in the head section. So, I write this code: add_action('wp_head', ...
2
votes
0answers
88 views

Action hooks returning old category instead of new category

With some help I created a WP Action to send an email to the author of a post (custom post type) when the category has been changed. This works ok, except that the function is returning the previous ...
0
votes
1answer
45 views

Why Should We Use wp_clear_scheduled_hook and What it Does?

I am new to cron job. After reading this article I was able to run a function every hour using wp_schedule_event. There is a quote on "Don't forget to clean the scheduler on deactivation" in that ...
4
votes
4answers
196 views

What is a good way to pass a variable from add_action to a Theme?

Inside functions.php: add_action('init','my_action'); function my_action() { if($dontknow) { $passme = "yes"; } else { $passme = "no"; } } Inside index.php of the ...