Tagged Questions

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

learn more… | top users | synonyms (2)

3
votes
2answers
103 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
252 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
206 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
282 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
798 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
490 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
130 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 ...
14
votes
3answers
4k 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
5k 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
265 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 ...
4
votes
2answers
723 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
110 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
488 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
643 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
569 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
197 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
59 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
665 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
311 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
740 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
357 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
428 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
187 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
320 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
154 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
686 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
6k 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
87 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
124 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
536 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
668 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 ...
1
vote
2answers
483 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 ...
4
votes
1answer
219 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
418 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 ...
0
votes
1answer
313 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 ...
1
vote
1answer
904 views

How to modify the action attribute of the wp-login.php?action=register form?

I'm trying to create a reference registration system in Wordpress. The idea is that the user will click a link which will contain wp-login.php?action=register&ref=12345 I'm hooking into the ...
3
votes
3answers
2k views

How to correctly get post type in a the_title filter

I want to prepend text to the post titles of a specific custom post type, but the filter below didn't work. Instead of changing only that CPT's post titles, it changed all titles on the given CPT's ...
0
votes
2answers
795 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 ...
6
votes
1answer
2k views

add_role() run only once?

I was surprised to discover that add_role() modifies the database and fails if the role already exists. There are two implications here, one first more serious than the other: 1) if you're in ...
0
votes
1answer
420 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 ...
0
votes
1answer
57 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 ...
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
65 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, ...
3
votes
3answers
5k views

add_action with a class method is causing fatal errors

I wasn't sure if this was a PHP issue (suited for StackOverflow) or a WordPress issue (suited for StackExchange), however since my issue appears to be with the add_action() function, I have placed the ...