Skip to main content
Updated explanation.
Source Link
Michael Ecklund
  • 6.8k
  • 13
  • 68
  • 110

Shot in the dark here, but...

It is entirely possible the plugin with the do_action definition is hooked before the theme is processed.

Find out where the do_action is defined, and find out when it is being hooked.

You might need to hook to the function that the do_action definition is hooked too, and THEN hook to that action definition.

Example:

Open the plugin file that has the do_action definition you are trying to hook to with your custom function.

Look to see if the do_action definition resides within a plugin function.

If so, look through the plugin to find an add_action() reference of that particular function name containing the do_action definition.

Note down what that hook is.

Now, you know when WordPress calls that plugin's function containing the do_action definition.

So now in your theme functions.php file, you might have something similar to the following code:

/**
 * This is the WordPress action the plugin's do_action function wpse_setup_themedefinition is 
 * hooked to.
 *
 * Example: This hook could be anything. I'm not saying the hook will be: "plugins_loaded" 
 * for sure, but if it was "plugins_loaded"... After WordPress loads and instantiates all 
 * of it's activated plugins, WordPress will fire the plugin's function containing the 
 * plugin's do_action definition (As long as the plugin you are trying to work with is 
 * activated){. So you're getting on the same level as the plugin when it needs WordPress to 
 * execute this particular defined custom action and telling WordPress that your theme function
 * needs to be on that same level as well, before it can hook to your plugin's do_action reference.
 */
add_action('your_do_action_hook_name''plugins_loaded', 'wpse_display_theme_header''wpse_setup_theme');/
function wpse_setup_theme(){
    /**
     * This your function that you want fired then the do_action is executed.
}     *
add_action     * Example: If the plugin file has a function named osmosis_jones('plugins_loaded',) 'wpse_setup_theme'and 
     * inside osmosis_jones();//, Thisthere is thea samedo_action() hookreference. Note down 
     * the do_action istag hookedname toinside the osmosis_jones() function.
     */
    add_action('the_plugin_do_action_tag_name', 'wpse_display_theme_header');
}

function wpse_display_theme_header(){
    echo 'THEME HEADER HERE!';
}

Shot in the dark here, but...

It is entirely possible the plugin with the do_action definition is hooked before the theme is processed.

Find out where the do_action is defined, and find out when it is being hooked.

You might need to hook to the function that the do_action definition is hooked too, and THEN hook to that action definition.

Example:

function wpse_setup_theme(){
    add_action('your_do_action_hook_name', 'wpse_display_theme_header');// This your function that you want fired then the do_action is executed.
}
add_action('plugins_loaded', 'wpse_setup_theme');// This is the same hook the do_action is hooked to.

function wpse_display_theme_header(){
    echo 'THEME HEADER HERE!';
}

Shot in the dark here, but...

It is entirely possible the plugin with the do_action definition is hooked before the theme is processed.

Find out where the do_action is defined, and find out when it is being hooked.

You might need to hook to the function that the do_action definition is hooked too, and THEN hook to that action definition.

Example:

Open the plugin file that has the do_action definition you are trying to hook to with your custom function.

Look to see if the do_action definition resides within a plugin function.

If so, look through the plugin to find an add_action() reference of that particular function name containing the do_action definition.

Note down what that hook is.

Now, you know when WordPress calls that plugin's function containing the do_action definition.

So now in your theme functions.php file, you might have something similar to the following code:

/**
 * This is the WordPress action the plugin's do_action function definition is 
 * hooked to.
 *
 * Example: This hook could be anything. I'm not saying the hook will be: "plugins_loaded" 
 * for sure, but if it was "plugins_loaded"... After WordPress loads and instantiates all 
 * of it's activated plugins, WordPress will fire the plugin's function containing the 
 * plugin's do_action definition (As long as the plugin you are trying to work with is 
 * activated). So you're getting on the same level as the plugin when it needs WordPress to 
 * execute this particular defined custom action and telling WordPress that your theme function
 * needs to be on that same level as well, before it can hook to your plugin's do_action reference.
 */
add_action('plugins_loaded', 'wpse_setup_theme');
function wpse_setup_theme(){
    /**
     * This your function that you want fired then the do_action is executed.
     *
     * Example: If the plugin file has a function named osmosis_jones() and 
     * inside osmosis_jones(), there is a do_action() reference. Note down 
     * the do_action tag name inside the osmosis_jones() function.
     */
    add_action('the_plugin_do_action_tag_name', 'wpse_display_theme_header');
}

function wpse_display_theme_header(){
    echo 'THEME HEADER HERE!';
}
Source Link
Michael Ecklund
  • 6.8k
  • 13
  • 68
  • 110

Shot in the dark here, but...

It is entirely possible the plugin with the do_action definition is hooked before the theme is processed.

Find out where the do_action is defined, and find out when it is being hooked.

You might need to hook to the function that the do_action definition is hooked too, and THEN hook to that action definition.

Example:

function wpse_setup_theme(){
    add_action('your_do_action_hook_name', 'wpse_display_theme_header');// This your function that you want fired then the do_action is executed.
}
add_action('plugins_loaded', 'wpse_setup_theme');// This is the same hook the do_action is hooked to.

function wpse_display_theme_header(){
    echo 'THEME HEADER HERE!';
}