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

learn more… | top users | synonyms (2)

5
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
760 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 ...
0
votes
1answer
919 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 ...
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
196 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
703 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
226 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
2answers
836 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." ;); } ...
0
votes
1answer
192 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
227 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'); ...
0
votes
1answer
404 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 ...
0
votes
1answer
234 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
592 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
107 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 ...
0
votes
1answer
422 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
2answers
624 views

Editing wp-config.php

I need to add the line define('WP_POST_REVISIONS', false); to my config.php , so that post revisions are disabled. I don't have access to wp-config.php, I have permission to edit my theme and ...
0
votes
3answers
531 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
491 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
170 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
55 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
511 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 ...
3
votes
1answer
3k views

Difference between after_setup_theme and init action hooks?

What is the difference between the after_setup_theme and init action hooks? It seems they are both called right before any page in WordPress is loaded (even admin pages).
0
votes
1answer
609 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 ...
2
votes
2answers
1k views

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

I'm having the exact same problem described in this post: add_action('wp_ajax_[action name]', myfunction) problem I set add_action('wp_ajax_my_function_call','my_ajax_function'). If I ...
1
vote
1answer
337 views

how to set array of args for scheduled event?

I have a scheduled event that runs twice daily in my plugin, the action is registered with add_action('fhprw_action','fhprw_check_fetch'); function fhprw_check_fetch($args){ $type=$args['type']; ...
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( ...
3
votes
3answers
1k 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
84 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
115 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
319 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.
1
vote
2answers
590 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 ...
4
votes
1answer
201 views

Why, Where, and When to use reference pointers in filters/hooks?

Why, Where, and When to use reference pointers in filters/hooks? What are the potential cons of not using them when suggested or required? Just looking for a more detailed answer than the codex ...
0
votes
1answer
405 views

comment_post callback function: how to run it in the background.

I'm calling a custom function when someone submits comments using the following to plug into the comment_post action: add_action('comment_post', 'MY_FUNCTION'); The problem is that my function is ...
4
votes
5answers
585 views

Implementing advanced add_* function wrappers

add_action() and add_filter() are major functions. However in some scenarios add one more function and hook it somewhere approach gets bulky and inconvenient. I had determined for myself several use ...
0
votes
1answer
250 views

add action for displaying posts using a shortcode

I'm developing a simple plugin for letting a user insert a post from the frontend. I have a shortcode [add-post] which a user can put on any page, say, for eg. My Wall Page Now on My Wall Page a ...
0
votes
1answer
388 views

Using add_action before add_filter on a plugin?

I'm writing a plugin and having a problem. I have add_action('publish_post', 'sender'); and I want this function to run first before the add_filter function, although it won't. Is there a way to do ...
6
votes
3answers
2k views

Conditional wp_enqueue_script on a page

For efficiency we are trying to hook some JS scripts only a certain page template of a theme that is to hold a form: page-with-form.php On the theme functions.php we've defined a init_method as ...
0
votes
1answer
56 views

Is there a way to figure out which action/filter invoked a function?

I'd like a lightweight way to figure out what is invoking a certain action in an effort to provide logic for certain scenarios where I can't help to avoid a function invocation (for example, a new ...
0
votes
1answer
63 views

Actions to use when flushing cache (when posts are added / deleted / modified)

I'm looking for a list of action tags that are relevant when you: create a post, with any method, so basically using wp_insert_post modify a post, like changing status, title, content, terms, meta, ...
0
votes
1answer
161 views

I cannot include a file in my plugin settings page

I'm trying to create a settings page. If I print things within index, I can see it. If I try to include it, I can't see anything, neither errors. add_options_page('My Plugin', 'My Plugin', ...
3
votes
1answer
1k views

What is the very earliest action hook you can call?

After the solution to this question was to get a function to launch BEFORE the init action is fired by taking the sequence out of its function, it got me thinking, is there any earlier in the WP load ...
0
votes
2answers
592 views

Where do I put my add_action(… and add_filter(… and do I need to remove them?

I'm working on creating a plugin out of some custom code I use a lot, in hopes that other people find it useful too. It works, so yay! but... Here's my question: I feel like I'm missing some ...
0
votes
1answer
450 views

create function to call category name and slug

In several theme templates I have code to retrieve the category name and slug for the present post or category page. It is outside the loop. Here is the repeated code: global $post; $categories = ...
0
votes
1answer
232 views

Post via wp-admin and via iOS app, same hooks and triggers involved?

I've got an add_action in functions.php, the action is for save_post and the function I'm running I've named set_attachment_url. I'm simply getting the first attachment on a post and setting a custom ...
0
votes
1answer
177 views

Which hook to use when adding ajax to viewer-facing side?

I have a shortcode that contains a form. I want to use jQuery/Ajax for POSTing. For this, I want to add javascript to the page where shortcode is added? Which hook should I use? wp_enqueue_scripts ...
3
votes
2answers
704 views

Correct place to register and enqueue scripts

I'm queueing several scripts in my themes Functions.php: if ( ! function_exists('b99_init_scripts') ) : function b99_init_scripts(){ if ( !is_admin()){ ...
0
votes
1answer
226 views

I add some js files from a plugin to a specific location

How Can I add some js files from a plugin to a specific location with add_action I am Using this widget: ...
1
vote
2answers
1k views

What hook should be used to programmatically create a post only when master post is updated?

Pippin and Jean-Baptiste Jung have very good tutorials on how to programmatically create content when a new post is published using these four actions hooks... publish{post_type} ...
1
vote
1answer
1k views

How can I automatically set a post slug based on the post title during post publish?

When you create a post in WP, if you don't specify a title rapidly, WP generates a default slug on autosave, based on the post ID. Then, when you add the title later, unless you modify the slug by ...