Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I'm at my wits end. I'm beginning a project that may involve using an action hook in WP that is not well-documented: edit_{$taxonomy}

I'm trying to determine exactly when this hook runs, so I just wrote a basic function with an echo for testing. Then, I added it to functions.php in a child theme. Invariably, the line with the echo causes a "Headers already sent" error. If I comment out the echo, it's fine. I thought it might have something to do with the order in which php files are loaded when using child themes, so I went head and pasted it into the bottom of the parent theme functions.php. Same issue.

Here's the code:

add_action('edit_expedited-status', 'category_status_email');
function category_status_email() {
echo "Testing";
}

Any thoughts or ideas appreciated.

Update

Note: Update not from author

On /wp-includes/taxonomy.php, you'll find (v3.3) on line 1586 the following filter under the context/action edit:

$value = apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id);
share|improve this question
    
I can't find any action named 'edit_{WHATEVER}-status' in core. Could you please point at the file + file number? –  kaiser Jan 31 '12 at 2:58
    
It's not listed in the Codex. It is listed on Adam Brown's hook directory: adambrown.info/p/wp_hooks/hook/edit_%7B$taxonomy%7D. –  mburtis Jan 31 '12 at 3:55
    
Just to be clear, the custom taxonomy I'm using has an id of "expedited-status" that's why the hook is "edit_expedited-status". It's a variable hook. –  mburtis Jan 31 '12 at 3:56
    
Also, I'm not sure why someone changed the title of the post. While I am, ultimately, trying to determine the role of this hook, this post is specifically about the strange header error I'm getting. I reverted. –  mburtis Jan 31 '12 at 3:58
    
WordPress is probably trying to send headers after you echo. If you echo "Testing";die(); you won't get that error. I'm a little unclear about what your question is -- do you want to know when edit_$taxonomy runs? –  Matthew Boynes Jan 31 '12 at 4:15

2 Answers 2

Please have a read on how to work with filters and actions (I'm not repeating it here).

The filter in a theme or plugin

// inside /wp-includes/taxonomy.php on line 1586
$value = apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id);

// inside some theme file that runs before - best on functions.php during your themes bootstrap:
function wpse40709_edit_tax_field( $value, $term_id )
{
    // Do modifications

    return $value;
}
// Should be hooked in bootstrap, so best would be 'after_setup_theme' until 'admin_init'
add_filter( 'edit_YOUR-TAXONOMY-NAME_YOUR-FIELD-NAME', 'wpse40709_edit_tax_field', 20, 2 );

The filter in core

The filter gets triggered, when

sanitize_term_field($field, $value, $term_id, $taxonomy, $context)

runs. So the $field is whatever name your field has.

share|improve this answer

I think the problem is that you need to run the hook during init

share|improve this answer
1  
Please, elaborate the Answer a bit more... Code example? –  brasofilo Oct 25 '12 at 0:34
    
Please improve your answer. Explain why your suggestion solves the issue. –  toscho Oct 25 '12 at 5:44

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.