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

learn more… | top users | synonyms (2)

2
votes
2answers
121 views

What's the best action to use when you want to do something only once per theme setup?

I'm writing a theme which has it's own set of database tables. I'm wondering what is the best action for me to use when I want my install function to be invoked only once when the theme is activated ...
6
votes
1answer
2k views

How to override existing plugin action with new action

I'm using a plugin. It has an action like this. add_action('publish_post', 'old_action'); function old_action($pid) { "code goes here" } } I'm writing a module for this plugin. So i need to ...
0
votes
1answer
1k views

Getting admin notices working for plugin errors

I'm beginning with creating plugins and I don't quite understand the process of displaying error messages. e.g. I use the php readfile function to download a file from a hidden location. If something ...
0
votes
1answer
851 views

prevent post submission

I'm using a meta-box for custom post type. I have three problems: WP seems to run the function that I attached to the "save_post" action, every time a new post is opened for editing or reloaded. Is ...
1
vote
2answers
1k views

How to get post ID in post_updated action hook?

I want to execute a function, myfunction() [hypothetically named], whenever a page is updated in the admin. The function doesn't do anything to the content that is saved—it just runs an unrelated task ...
3
votes
1answer
2k views

When and Where to use wp_insert_post()

I'm building a function that creates a group of pages with a common parent ID. If I run wp_insert_post() on a parent ID twice, does the function create the pages twice while altering the slugs? Or am ...
0
votes
1answer
221 views

action wp_set_comment_status never gets fired when i change the comment status [closed]

I want to run some code on comment status change so using the action wp_set_comment_status but it seem to never fired when comment status gets changed. I am using wordpress 3.3.1. Here is a simple ...
1
vote
1answer
454 views

Does BuddyPress Have An Action Hook for remove_user?

BuddyPress has a behavior for removing users that does not run through WP's deleted_user action. I have a hook in my plugin for add_action('deleted_user', 'myScript'); but it only works for ...
1
vote
2answers
2k views

Hook to get image filename when it is uploaded

I want to get the full local filename of an uploaded image so that I can copy it to a new directory and process it with my own image processing scripts. Which hooks/actions should I look into to ...
1
vote
2answers
155 views

how to determine how many and what kind of arguments are passed to hooks

I am not able to understand a very logic behind add_action / add_filter Consider following example: function SearchFilter($query) { if ($query->is_search) { $query->set('post_type', ...
2
votes
2answers
429 views

Run javascript code after wp_login hook?

After using the wp_login hook, is it possible to add a snippet of javascript code to the page seen immediately after the login in wordpress? I want to use this top implement a notification system ...
0
votes
2answers
980 views

Get post id in wordpress action?

I have this code add_action( 'delete_post', 'my_delete_function' ); function my_delete_function() { global $wpdb; $wpdb->query(" DELETE FROM wp_votes WHERE post=".$thePostID." ;); } ...
3
votes
2answers
101 views

Which to use to execute code during the saving of a plugin settings page?

I'm writing a plugin with a settings/option page and I want some php code to be executed whenever someone saves the settings on that page and that page alone. Which actions do I need to hook into to ...
0
votes
1answer
235 views

save_post action doesn't passing post id to my function as argument

I'm adding a box to add / update post screen. add_action( 'save_post', 'psd_upload_kaydet' ); add_action( 'add_meta_boxes', 'psd_upload' ); function psd_upload() { add_meta_box("psd-upload", "Bir ...
0
votes
1answer
198 views

Setting post_id for single.php based on URL without a redirect

I'm migrating a Joomla! database to Wordpress and the website has to remain exact regarding URLs. The Joomla site has its posts with .html extensions, and the importer I created maps the Joomla file ...
0
votes
1answer
260 views

How to use add_action inside files included by theme's functions.php

I've a functions.php inside my theme folder. The first line of functions.php is require_once 'custom.php'; inside custom.php I have this simple code: add_action('wp_print_scripts','add_js_vars'); ...
1
vote
1answer
757 views

When to load auto-login code?

I'm using this (simplified) code to automatically login users via a plugin for a single sign-on system: $user_info = get_userdatabylogin( $username ); $user_id = $user_info->ID; ...
0
votes
1answer
465 views

A unique wp_schedule_single_event() for each post?

I'm building a site for a client that requires sending out emails about each post at various dates (i.e. two weeks before after the post was published, then again four weeks after the post was ...
1
vote
0answers
152 views

Save modified Custom Field content into another Custom Field on article save [closed]

In my articles I allow editors to enter a date in a human readable dd.mm.yyyy format into a custom field. But I also need this date as unix timestamp in the DB. So I wrote a function which takes the ...
0
votes
1answer
125 views

An action that runs after each post in the loop on index/archive page?

Is there an Action/a Filter that runs just after each post/post excerpt is displayed on these 2 pages? I use the_content and get_the_excerpt currently, but the_content causes a conflict with some ...
2
votes
2answers
1k views

add_action for saving a custom menu

Say you have custom menus enabled with your WP theme. Is there any action associated with saving a menu once you've arranged it accordingly? To further clarify: say you've arranged a menu with some ...
8
votes
3answers
3k 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
2answers
4k 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 ...
0
votes
1answer
242 views

How can I override one post and make it display content for another post?

I have two pages on my Wordpress site: mysite.com/?p=100 mysite.com/?p=200 I think I should be able to hook into Wordpress' actions somewhere and re-query the post, so that content for ...
3
votes
2answers
670 views

How can I log a user out of Wordpress before the page loads?

I would am using the code below so that on my wordpress site if ?logout is appended to the end of the URL the user will be logged out. This works well - if the user visits a page such as ...
0
votes
1answer
108 views

Change status of page after an event (Looking for best practice advice)

I'm looking for a best practice/ideas for modifying the status/data of a page after an event. Here's an example of what I'm trying to accomplish - This WordPress site would allow users to sponsor ...
2
votes
1answer
2k views

How can I see all the actions attached to an “add_action” hook?

I'm working with the admin bar and trying to debug some of the menus and their priorities. I know several callbacks get bound to actions, such as this one: add_action( 'admin_bar_menu', ...
0
votes
1answer
454 views

How to Trigger comment_form_after action if comment_form() not used

A plugin I want to use has a filter like so: add_action('comment_form_after','yoast_track_comment_form'); The theme I'm using doesn't use the comment_form() call and I believe that this means ...
0
votes
3answers
592 views

Run a plugin just 'once' per page reload

I'm making a plugin that counts the number of times a visitor visits my site. I want to run the code in the plugin once per page load. What's a good action hook I can use ?
0
votes
1answer
537 views

Anonymous function is executed twice in wp_head while added from the_posts filter?

I know this sounds complicated, so bear with me. I'm trying to add certain custom css styles based on the shortcodes(if any) in the current post/page. function load_shortcode_styles($posts){ ...
1
vote
1answer
185 views

Can taxonomies of custom post types be used with category actions?

I need to create a hook after the creation, edit and deletion of a taxonomy organizing a custom post type I have. I've noticed though that I can't use the following actions with those taxonomies: ...
3
votes
2answers
56 views

How can I limit functionality in one version of a plugin?

I am busy writing a plugin with a free version and a paid, Pro version. For our initial release of both versions, I want to keep things as simple as possible, so I would rather defer using a strategy ...
0
votes
1answer
582 views

admin_notices not displaying in plugin

I know I'm probably doing something dumb here but I just can't get this to run. I'm trying to set up a little API for my plugin and to create a class to display admin notices a little easier. Here's ...
1
vote
2answers
289 views

Problem with get_the_excerpt when using an add_action('the_content') containing script tags

Because of the add_action I'm doing on get_content(), where I'm appending social media icons to the end of the post, it appears that calls to get_the_excerpt() are picking up the part of the ...
0
votes
1answer
679 views

Hook for page Request?

I want to run a function that looks at the current url params of the page that is requested and sets a cookie based on those params. So, I guess I'm looking for: The Wordpress Hook that allows me ...
3
votes
2answers
324 views

Add new column to sites page

I'm trying to get info into my network sites page in a column. Below works great to grab the network site ID for each site. How can I make it display the option_value for the item (blog_expire) in ...
0
votes
2answers
411 views

problem loading stylesheets to wp_head dynamically

I'm trying to create a wrapper shortcut function to register and load stylesheets in the header. currently, the function loads this css file src: http://my.test/wp-content/theme/css/.css I, ...
1
vote
1answer
184 views

Combining action and filter?

I tried to set up different video oembed size for content and sidebar. I can set up video size with embed_defaults filter. But this filter works for the whole site and I need to have smaller video ...
1
vote
2answers
311 views

WP_cron won't trigger my action

I'm in a dead end with a schedualed task in a wordpress plugin for a multisite. Somehow the action I added don't get triggered. The task is getting schedualed and returns a timestamp when I run ...
-2
votes
3answers
142 views

Apply function on all action hooks?

Is there an easy way to apply a function on all action hooks? I want to apply esc_attr() to every action hook (in a way that would work from functions.php or a plugin). I figure I would need ...
2
votes
1answer
630 views

Better way to enforce category hierarchy in post_categories_metabox?

The objective is to ensure that when editing a post, the metabox that lists a hierarchical taxonomy doesn't reorder itself upon Update to put checked items on top. Right now, edit-form-advanced.php ...
0
votes
1answer
1k views

add_action not using 'delete_post' action with wp_delete_post

I am using wp_delete_post function to delete the selected posts shown on the front-end (in my theme page). Posts are being deleted successfully. // delete all selected posts foreach( ...
2
votes
2answers
1k views

Action wp_login_failed not working if only one field is filled out

I created a login form in the frontend with wp_login_form(). In my functions.php file I added an action to prevent the redirect to /wp-login.php if the login failed with ...
6
votes
2answers
5k views

Is there a hook that runs after a user logs in?

I am writing a plugin that fetches some extended user info from a remote service and I need it to execute its function each time a user logs in. Is there a hook that gets fired after login that I can ...
1
vote
2answers
86 views

Same Conditionals Not Working on Two Different Hooks

Everyone! I am new to WP and trying to build a plugin. I have the following codes working properly: add_filter('the_content', 'say_hello'); function say_hello($content){ if(is_single() || ...
0
votes
1answer
118 views

output custom Posts on a Page

I'm trying to write a function that will output a set of posts on a page. Because I want to display more than just the post titles, wp_get_archives() won't do (I think). The function to add the post ...
1
vote
1answer
390 views

How can I tell if I'm on a login page?

There are functions for is_home(), is_blog() is_single() etc... What's the best way to tell if I'm on a page that is requesting that I login? I guess that would just be the wp-login.php page.
3
votes
3answers
2k views

How to publish a post with empty title and empty content?

Why I'm doing this you might ask? I'm developing a website for a business with a portfolio where the gallery items are posts. These posts are populated through custom fields and category selections, ...
1
vote
2answers
639 views

How do I add a TinyMCE row that all users can see, instead of just admins?

Currently I have successfully added a row of shortcode buttons to the TinyMCE editor in WordPress. The problem is, only admins can see the row, and I need contributors and editors to see it too. I ...
0
votes
2answers
415 views

What would cause the 'wp' action to fire twice per page (but only once per post) in Firefox only?

I'm using add_action( 'wp', 'do_something_once_per_page' ); and, well, it's not doing it just once but twice. What's interesting is that within do_something_once_per_page( $wp ){ } I'm globalizing ...