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

learn more… | top users | synonyms (2)

0
votes
1answer
14 views

execute custom function on database connection error

is it possible to execute a function on wordpress db connection error? I mean is there any hook or something in the (error stablishing database connection) thing...? I want to do something when I get ...
1
vote
1answer
832 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
975 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 style....
3
votes
1answer
98 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 ...
2
votes
1answer
511 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 ...
0
votes
1answer
411 views

register_post_type not working in wordpress 3.6

I am using WP3.6 and am having trouble adding a new post type. I have put echo statements in the code and know that a) the function calling register_post_type gets called b) the post type name i am ...
0
votes
1answer
17 views

add_action not working within widget() of WP_Wdiget

I have a function in functions.php function test(){ do_action('before_test_action'); echo 'in test'; } Then within my Widget, in the widget( $args, $instance ) function i use: $boolean = (...
0
votes
0answers
16 views

creating posts from excel random number of posts are created

I'm creating a plugin to import posts from a CSV file. The plugin is creating posts, but a random number of posts are created with an infinite loop. I have checked the while loop and for loop, they ...
0
votes
1answer
15 views

WP_LIST_TABLE bulk action

I created a class extend WP_List_Table and created method for bulk actions like this : function get_bulk_actions() { $actions = array( 'synchronize' => 'Synchronize', ...
0
votes
2answers
491 views

stumped on add_action hook to delete_comment - any ideas?

I'm trying to run a function when deleting a comment. This entails hooking into "delete_comment" if I'm not mistaken. Theoretically, this should work as a plugin, so when you delete a comment, it ...
0
votes
1answer
20 views

What is the action hook to use if you want to capture the new password during password change?

Clicking the Update Profile button in the [wordpress]/wp-admin/profile.php admin screen will allow the user to update his/her profile including the password. What is the right action hook to use ...
0
votes
1answer
422 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 following:...
0
votes
1answer
30 views

Does WordPress have something like timer hook?

Are there some timer hooks to trigger event like this? add_action("one_min_timer", "my_handler"); function my_handler() { //checking something every 1 min }
1
vote
0answers
25 views

How to get list of all hooks of current theme / plugin?

I want to get the list of all available hooks from active theme / from a specific plugin. I was tried to get it from global variables $wp_actions & $wp_filter But, They are showing all registered ...
0
votes
3answers
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.
1
vote
1answer
43 views

Reuse variable in hook callback

I'm setting up a child theme in WordPress and I can't make add_action to be fired within functions.php. Functions.php is called and I can run code from within. Any idea on what I'm doing wrong? $...
0
votes
2answers
23 views

How to access author data from header action

I am adding a function to the header: add_action('wp_head', 'mine'); function mine() { global $authordata; $avatar_url = get_avatar_ur($authordata->user_email); // .... } But I am getting ...
0
votes
1answer
432 views

Change meta tags programatically

Is there a way to change the meta tags not in the head but in a template file through code? I would like to change the meta tags <meta property="og:title" content="title" /> <meta ...
4
votes
2answers
775 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
1answer
537 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 = ...
0
votes
0answers
19 views

How can I get post meta data (custom field) from within a custom wordpress action hook?

I have a custom hook in my theme which is set up like this: do_action('my_custom_hook'); That code is in my header.php file and outside of the main loop. I have a call to this hook like so in my ...
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 = $wpdb->...
0
votes
4answers
5k views

add action wp_head not working

I am trying to add some code to the head (namely a block of tracking script) via a plugin I am making. The plugin has an interface where the user enters some details which are then added to the ...
0
votes
1answer
1k 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 ...
0
votes
4answers
339 views

wp_ajax action responds with 0

I'm writing a plugin. There is a button, that triggers an ajax-request to an action I added in my plugin page: Head of my plugin PHP file: add_action('wp_ajax_update_nav_items', 'update_nav_items' )...
1
vote
2answers
3k views

wp_ajax action is not running

I'm writing a plugin. I want to run the method get_my_option when someone pressing a button in the settings page of my wordpress plugin. The ajax call is made but the method never runs. In the page I ...
3
votes
2answers
7k views

add_action('wp_ajax_[action name]', myfunction) problem

I'm trying to integrate ajax in wordpress using the wp codex guidelines. In the PHP I added: wp_enqueue_script ( 'my_ajax', ADMIN_URL . 'js/ajax.js','jquery','1.0.0' ); wp_localize_script( 'my_ajax', ...
0
votes
0answers
20 views

Can you update a post with content from a DIV?

I'm very new to PHP and am wondering if, within wordpress, I can create a function/action that will update a post_content with the data inside a div with a class="output-box"? I have found an example ...
0
votes
0answers
16 views

Sending Messages Back to the Template After Processing?

Is there an "offical" way to send a message back to the template after processing a form using add_action('admin_post') or similar for client-side feedback ? I was thinking of using the $_SESSION but ...
3
votes
2answers
442 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
1answer
429 views

Custom login modal page action

I have a modal login and I also have a custom login page as well. modal login page is mostly being used for login, register, forgot password. The problem is whenever you login by modal login page, ...
3
votes
1answer
92 views

Why is there both a save_post and wp_insert_post action?

I just realised that in wp-includes/post.php (source), at the end of wp_insert_post(), both the save_post and wp_insert_post actions are called one after the other, with the exact same parameters: ...
2
votes
1answer
684 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 ...
5
votes
2answers
261 views

Content hooks vs User hooks

This is more of a theory question than a question with a direct answer. I've been working with different actions for firing functions when a post is updated or deleted and when users are updated or ...
4
votes
1answer
49 views

Is there a global action for when a plugin is uninstalled?

I need to do something anytime any plugin is uninstalled. There's a hook for when MY plugin is uninstalled but I don't see an uninstall equivalent of deactivated_plugin. Does uninstalling a plugin ...
0
votes
1answer
31 views

Move jQuery on *top* of footer

I am using this code by Peter Wilson to move jQuery to footer: function pwcc_jquery_to_footer( &$wp_scripts ) { if ( is_admin() ) { return; } /* Move jQuery to the ...
0
votes
1answer
76 views

How to trigger function on theme delete?

Tried to find an or some hook to fire a function when theme is being delited, but didn't find any hook.. May be someone can tell if there's a way to fire my function on themes delete event? I need ...
2
votes
2answers
88 views

do_action and hook methods

I am trying to understand how hook methods work in WordPress. I understand that when do_action is called WP looks for all registered listeners and invokes them according to set priority. How does ...
9
votes
9answers
3k views

Remove an action from an external Class

I'm trying to do something similar to this question here: remove_action or remove_filter with external classes? I'm trying to remove the <!-- This site is optimized with the Yoast WordPress ...
1
vote
2answers
646 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() { ...
0
votes
1answer
15 views

Add a filter to an action [closed]

I feel like this is a really simple question, but I can't seem to find anything. I want to add a filter to an action, so I can run preg_replace on it to add a class to a link. The action is: ...
0
votes
1answer
17 views

Custom comment action

I have updated my Wordpress version from 4.3.1 to 4.5.2 and apparently it broke a custom function I've made in the past. What it does: Display a anchor below comments, next to Approve/Answer/Edit/...
0
votes
2answers
68 views

Refresh page after form action

I've a listing post page where all posts are shown. On each post's row I can perform actions like delete, archive etc. So imagine that: I have an "archive" button; I push on it and I get a modal (...
0
votes
0answers
21 views

Init action and refresh page after form action

My problem is that I can't refresh the page after a form action into a loop. In my case I have a listing post page where I can delete, archive, deliver posts through a modal form, row by row. After ...
2
votes
1answer
37 views

return values from hooks do_action and apply_filters, which is better

Myself wondering among the following methods which is better to update an option value where value to be updated is coming from an ajax callback. Since Wordpress Codex clearly says apply_filters is ...
0
votes
0answers
18 views

How to Modify all of an action outputs

There's a plugin in my site that allows to introduce extra information with the following action call: do_action( 'bp_before_member_header_meta' ); Another plugin adds some of it with add_action: ...
2
votes
1answer
54 views

add_action customize_register not working

I've been working on this for a long time but can't get it fixed. I'm simply trying to get the function below to work but it's refusing to do that. I have put it in functions.php of my theme. ...
3
votes
4answers
12k views

How can I edit post data before it is saved?

I have a plugin and I would like to be able to run the post content through some filters before it is saved to the database. From looking at the plugin api, I see that two hooks that look like they ...
1
vote
1answer
38 views

How to filter content for specific content variable

I created a plugin that adds content from another post, and places this content next to the original content. I can say, that this content should appear at the bottom of the original post content. I ...
0
votes
1answer
28 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 add_action....