Tagged Questions
3
votes
1answer
70 views
Which action for triggering cron “wp”or “init”?
Which one do you recommend using within a plugin and why?
add_action( 'wp', 'trigger_me' );
function trigger_me() {
if ( !wp_next_scheduled( 'my_plugin_cron' ) ) {
...
1
vote
2answers
40 views
Replace a word with a word in the URL string
I'm trying to replace a word on every page for example "Denver" with a word from a URL string, so I'll have like ?city=Atlanta in the URL. So I was thinking of using PHP's GET to just get the city ...
0
votes
1answer
24 views
Is there an action for save_menu and/or update_menu?
I want to "save" my menus into transients. I want to update those when there's been any changes to the menus via the admin custom menus. I've looked for an action but can't see to find anything. ...
0
votes
0answers
22 views
How to pass CLASS function with arguments to add_action? [duplicate]
Possible Duplicate:
Passing a parameter to filter and action functions
This works:
add_action('hook', array($this, 'someFunction'))
These not:
add_action('hook', array($this, ...
1
vote
2answers
68 views
admin-ajax.php “ Missing argument 2” warning
I have the following code in functions.php
<script type="text/javascript">
var post_id = "1055"; // hardcoded post id for testing purposes
var type = "some_type";
var data = {action: ...
0
votes
1answer
199 views
Where is the best place to use add_filter
Should I use the function add_filter In my plugin's init action hook or just the in the main plugin script?
Since sometimes I found people is using filter all over the place and if I put in the init ...
3
votes
2answers
61 views
How to count number of functions attached to an action hook?
I have some actions like this
function simple_notification() {
echo '<div>This is a notification</div>';
}
add_action( 'site_notices', 'simple_notification' );
...
0
votes
1answer
57 views
Call do_action class's function
There is the following do_action
else
do_action( 'example', $this->nothing());
Where nothing() does exactly what it sounds like.
This logic is in a public function testFunction in a class ...
0
votes
1answer
127 views
frontend show edit profile with selected custom options
So I have many custom user profile fields.
When I use do_action( 'show_user_profile', $profileuser ); hook it displays all custom user profile fields..
But I would like to show only certain fields. ...
1
vote
2answers
330 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 ...
1
vote
1answer
584 views
add_action in functions.php, do_action in plugin?
I am trying to set an add_action function in my currently active WordPress theme functions.php file, for a defined do_action function within an activated WordPress plugin.
The add_action function in ...
1
vote
1answer
83 views
Valid filenames for add_action's first parameter
Some examples in WordPress' docs pass a filename to add_action rather than an action name. For example,
add_action( 'load-post.php', 'callback' );
add_action( 'load-post-new.php', 'callback' );
...
4
votes
1answer
69 views
Getting the action's tag name within the action
There's a function attached to a set of actions, like this:
add_action('some_tag', 'the_function');
function the_function($maybe_some_vars){
// ...
}
Is it possible to find out the action name ...
0
votes
3answers
260 views
How to get post ID with hooks publish_post, new_to_publish, etc
I have two plugins, one uses the function wp_insert_post(), the other has a code like this:
add_action('future_to_publish', 'myFunc', 10, 1);
add_action('new_to_publish', 'myFunc', 10, 1);
...
4
votes
1answer
573 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
443 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
121 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', ...
1
vote
1answer
577 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;
...
1
vote
1answer
562 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 ...
5
votes
3answers
1k 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.
Thanks in advance.
3
votes
1answer
2k 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).
